I have a JSF 2 application with the following code:
<c:set var="number" value="0" scope="view" />
<ui:repeat value="${items}" var="item" varStatus="itemIndex">
<c:if test="${item.boolProperty == true}">
<c:set var="number" value="${number + 1}" scope="view" />
</c:if>
<h:outputText value="#{item.name}" />: <h:outputText value="#{number}" />
</ui:repeat>
I want to increase the number depending on the property of the item in the loop. However, the condition seems not to work, since the value of number
always stays 0. If I remove the condition, the number
is incremented only once, or it is always 0 before incrementing, therefore it outputs 1. Could it be possible the number
var changes not to affect the number
var that is outside the loop? I believe the scope
attribute takes care of that.