Ajax is a convenient way to do this, and JSF 2.0 comes with ajax.
Here is an example:
<h:selectOneRadio value="#{a7.myCheckbox.state}"> <f:selectItem itemLabel="#{bundle.yes}" itemValue="1"/> <f:selectItem itemLabel="#{bundle.no}" itemValue="0"/> <f:ajax render="uawGroup"/> </h:selectOneRadio> <h:panelGroup id="uawGroup" layout="block"> <h:outputText value="#{bundle.wichmed}" rendered="#{a7.myCheckbox.state == 1}"/> <h:inputText value="#{}" id="myInput" rendered="#{a7.myCheckbox.state == 1}"/> </h:panelGroup>
h:panelGroup
will be displayed when you click yes in h:selectOneRadio
(itemValue == 1). Initially, it is 0 (set to bean "a7").
h:panelGroup
acts like a shell, since you can update components with ajax, which are actually displayed on the page ( h:outputText
and h:inputText
not initially displayed).
source share