i'm facing a problem and i can't solve :(
By choosing an item in a selectOneRadio, i want to set a specific variable :
<h:form id="form">
<p:selectOneRadio id="options" value="#{rechercheBean.choose}">
<f:selectItem itemLabel="Critere 1" itemValue="c1" />
<f:selectItem itemLabel="Critere 2" itemValue="c2" />
<p:ajax update="critere" />
</p:selectOneRadio>
<h:panelGrid columns="1" id="critere">
<c:choose>
<c:when test="#{monBean.choix eq 'c1'}">
<h:outputText value="Critere 1 :" />
<p:inputText id="cr1" value="#{rechercheBean.critere1}" />
</c:when>
<c:when test="#{monBean.choix eq 'c2'}">
<h:outputText value="Critere 2 :" />
<p:inputText id="cr2" value="#{rechercheBean.critere2}" />
</c:when>
</c:choose>
</h:panelGrid>
<h:commandButton value="Add critere" actionListener="#{rechercheBean.add}"/>
</h:form>
With the managedBean SessionScope, this code works but with the ViewScope, it doesn't works.
in ViewScope, the specific variable is null when i click on the button but if i remove the component , the specific variable is set !
I need to use to switch between inputext :(
how can i resolve my problem ?
Tx a lot !
replace the
<c:choose>
<c:when test="#{monBean.choix eq 'c1'}">
with
<panelGroup rendered="#{monBean.choix eq 'c1'}">
(replace both <c:when
)
also if you are using primefaces you can replace the <h:commandButton
with <p:commandButton
, or just add f:ajax
to your current <h:commandButton