richfaces - JSF 2.0 - using render/rerender to show/hide panel via radio buttons -
i using jsf 2.0 , richfaces 4. have user click on 1 of 2 radio buttons , have code display 1 of 2 panels, start out hidden. in original project, able 2 panels come unrendered , when clicked on 1 of radio buttons, see via println statements methods determine if each panel should rendered called expected input , returning true or false appropriate, neither panel rendered.
i set target of radio button in bean 1 of panels initialized rendered can tell 'render' code worked.
below stripped down/simplified version of code. less, in when click on radio button, don't see output method (checktype()) determines whether panel should displayed.
here .xhtml
<body> <h:form id="myform"> <rich:panel id="formpanel"> <h:selectoneradio id="myradio" value="#{mybean.type}" label="select 1 or two" layout="pagedirection"> <f:selectitem itemvalue="one" itemlabel="one" /> <f:selectitem itemvalue="two" itemlabel="two" /> <a4j:ajax ajaxsingle="true" event="click" immediate="true" rerender="parentpanel panelone paneltwo" /> </h:selectoneradio> <a4j:outputpanel id="parentpanel"> <rich:panel id="panelone" rendered="#{myb ean.checktype('one')}"> <div id="divone">div one</div> </rich:panel> <rich:panel id="paneltwo" rendered="#{myb ean.checktype('two')}"> <div id="divtwo">div two</div> </rich:panel> </a4j:outputpanel> </rich:panel> </h:form> </body> </html> here bean import javax.faces.bean.managedbean; import javax.faces.bean.sessionscoped;
@managedbean @sessionscoped public class mybean { private string type = "two"; public string gettype() { homecoming type; } public void settype(string type) { this.type = type; } public boolean checktype(string type) { boolean tmp = this.type.equalsignorecase(type); system.out.println("checktype: "+this.type+" == "+type+"? ("+tmp+")"); homecoming tmp; } } jsf richfaces render radio
No comments:
Post a Comment