In this case, we're using an h:selectOneRadio control. We want to show and hide the rich:Panel controls; we wrap them in an a4j:outputPanel and then just re-render that when the user clicks a radio element. Note that for radio buttons, we have to use the onclick event; onchange is for h:selectOneMenu and other select controls.
<h:selectoneradio value="#{webencode.requestType}" id="rdoRequestType" styleclass="radio" layout="pageDirection">We can't call the equalsIgnoreCase() method on a string from within an EL expression, so we use a Seam method call that returns true/false based on string equality:
<f:selectitem itemvalue="program" itemlabel="Series or Program">
<f:selectitem itemvalue="special" itemlabel="Special">
<a4j:support ajaxsingle="true" event="onclick" rerender="program">
</a4j:support>
<a4j:outputpanel id="program">
<rich:panel rendered="#{webencode.checkRequestType('program')}">
program stuff goes here
</rich:panel>
<rich:panel rendered="#{webencode.checkRequestType('special')}">
special stuff goes here
</rich:panel>
</a4j:outputpanel>
public Boolean checkRequestType(String requestType){With the a4j:support tag, we use AJAX to re-render the a4j:outputPanel when the user clicks the radio buttons. Then the custom checkRequestType() bean method is called and returns a Boolean based on the value of the radio button group.
return (this.requestType.equalsIgnoreCase(requestType)) ? true : false;
}
2 comments:
quite difficult for fresher to understand this code
thanks dev
Post a Comment