java - Using <c:when> with an enumeration -
i have jsp portlet needs display different markup according value of bean's property of enumeration type
public enum state { canceled, completed }
i used following code switch
<c:choose> <c:when test="#{item.state == 'completed'}"> <img src="ok.gif" /> </c:when> <c:when test="#{item.state == 'canceled'}"> <img src="ko.gif" /> </c:when> </c:choose>
but doesn't work. interestingly enough, returns false in both cases. item object (inside icefaces data table) backing bean state
getter+setter property. have been told compare enumeration string , use ==
operator, maybe that's not way.
so, question is: how use <c:when>
tag compare property enumeration value?
... the item object (inside icefaces data table) ...
then jstl indeed doesn't work. runs during view build time, not during view render time. can visualize follows: jstl runs top bottom first , hands on generated result containing jsf tags jsf in turn runs top bottom again. @ moment jstl encounters iterated jsf datatable #{item}
, null
, evaulate false
, jsf retrieve neither of images jstl.
you want use jsf tag instead. i'd suggest <h:graphicimage>
in combination rendered
attribute.
<h:graphicimage value="ok.gif" rendered="#{item.state == 'completed'}" /> <h:graphicimage value="ko.gif" rendered="#{item.state == 'canceled'}" />
Comments
Post a Comment