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 &lt;c:when&gt; 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

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -