for example: when I click on the button A. I get the following text : you have choosed A.
But when I change button, I get the same text, although the value of #{bean.str} changes
Here is my code :
<p:selectOneButton id="selectId" value="#{bean.str}">
<f:selectItem itemLabel="A" itemValue="1" />
<f:selectItem itemLabel="B" itemValue="2" />
<f:selectItem itemLabel="C" itemValue="3" />
<f:ajax event="change" render="tabView" listener="#{bean.change}" />
</p:selectOneButton>
<c:if var="test" test="#{bean.str =='1'}">
<h:outputText value="you have choosed A" />
</c:if>
<c:if test="#{beanApplication.perspective=='2'}">
<h:outputText value="you have choosed B" />
</c:if>
<c:if test="#{beanApplication.perspective=='3'}">
<h:outputText value="you have choosed C" />
</c:if>
I am looking for a way to refresh the JSTL <c:if> test when I click on the button.
JSTL runs during JSF view build time, not during JSF view render time. However, the submitted value is in this particular example only set as bean property after view build time. The view build time runs during JSF RESTORE_VIEW phase, but the bean property is set during JSF UPDATE_MODEL_VALUES phase.
You need to evaluate the condition during render time instead. Use the therefor provided JSF component’s
renderedattribute.Further, you should be using
<p:ajax>in PrimeFaces components, not<f:ajax>. Also you should ensure that the component referenced astabViewin<f:ajax render>(and equivalently, the<p:ajax update>) covers the above three components. Here’s a complete kickoff example:See also: