Facelet:
<h:dataTable value="#{item1.zapas}" var="item2" >
<h:column>
<h:outputText value="#{item2.hrac == null}"/>
<c:choose>
<c:when test="#{item2.hrac == null}">
<h:outputText value="X"/>
</c:when>
<c:when test="#{item2.hrac != null }">
<h:outputText value="#{item2.vysledok}"/>
</c:when>
</c:choose>
</h:column>
</h:dataTable>
Output:
trueX
falseX
falseX
trueX
item.hrac is sometimes null and sometimes not null but in my choose it still choice null. So what is wrong? How can I solve it?
JSTL tags and JSF tags doesn’t run in sync as you’d expect from the coding. JSTL tags runs during JSF view build time only and the result is a tree of only JSF tags. JSF tags runs during view render time only and the result is a tree of only HTML elements.
When it’s JSTL’s turn to run during view build time, the
#{item2}is not available in the scope simply because JSF hasn’t run at that point.To overcome this, you want to use JSF
renderedattribute instead. Get rid of the whole<c:choose>block and put the following in place:See also: