java - JSF and f:ajax for hiding/showing div -
i thinking of making hidable/showable menu on web application. before this, used php , ajax extensively purpose. however, since html element id regenerated in jsf framework found out method no longer feasible @ least in scope.
i have read f:ajax tag in jsf , tried implement it. apparently no luck me. looks easy still not find out did wrong.
i have prepared prototype test f-ajax tag functionality no luck. here code
` <h:body> <h:outputlabel> <h:outputtext value="click a" /> <f:ajax event="click" render="texta"/> </h:outputlabel> <h:outputlabel> <h:outputtext value="click b" /> <f:ajax event="click" render="textb"/> </h:outputlabel> <h:outputlabel> <h:outputtext value="click c" /> <f:ajax event="click" render="textc"/> </h:outputlabel> <h:outputtext id="texta" value="click a" /> <h:outputtext id="textb" value="click b" /> <h:outputtext id="textc" value="click c" /> </h:body>`
when clicked particular label, nothing happend. texta, textb , textc elements rendered in first place. did wrong guys?
thanks in advance.
however, since html element id regenerated in jsf framework
if important, specify fixed id
s yourself. each component has id
attribute that. way should able use normal js/jquery frameworks whenever applicable.
as problem in concrete question, here's working example should started.
<h:form> <f:ajax render="text"> <h:commandlink value="click a" action="#{bean.setshow('a')}" /><br/> <h:commandlink value="click b" action="#{bean.setshow('b')}" /><br/> <h:commandlink value="click c" action="#{bean.setshow('c')}" /><br/> </f:ajax> <h:panelgroup id="text"> <h:outputtext value="clicked a" rendered="#{bean.show == 'a'}" /> <h:outputtext value="clicked b" rendered="#{bean.show == 'b'}" /> <h:outputtext value="clicked c" rendered="#{bean.show == 'c'}" /> </h:panelgroup> </h:form>
in combination with
@managedbean @viewscoped public class bean { private string show; public string getshow() { return show; } public void setshow(string show) { this.show = show; } }
Comments
Post a Comment