Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4007890
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:41:11+00:00 2026-05-20T08:41:11+00:00

I have a JSP portlet that needs to display different markup according to the

  • 0

I have a JSP portlet that needs to display different markup according to the value of a bean’s property which is of an enumeration type

public enum State {
    CANCELED, COMPLETED
}

I used the following code to do the 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 it doesn’t work. Interestingly enough, it returns false in both cases. The item object (inside an ICEFaces data table) is a backing bean with a State getter+setter property.
I have been told to compare the enumeration to a string and use the == operator, but maybe that’s not the way.

So, my question is: how do I use the &lt;c:when&gt; tag to compare a property to an enumeration value?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T08:41:12+00:00Added an answer on May 20, 2026 at 8:41 am

    … The item object (inside an ICEFaces data table) …

    Then JSTL indeed doesn’t work. It runs during view build time, not during view render time. Basically you can visualize it as follows: JSTL runs from top to bottom first and then hands over the generated result containing JSF tags only to JSF which in turn runs from top to bottom again. At the moment JSTL encounters the iterated JSF datatable #{item}, it is null and thus it will always evaulate false and JSF will retrieve neither of those images from JSTL.

    You want to use a JSF tag instead. I’d suggest <h:graphicImage> in combination with the rendered attribute.

    <h:graphicImage value="ok.gif" rendered="#{item.state == 'COMPLETED'}" />
    <h:graphicImage value="ko.gif" rendered="#{item.state == 'CANCELED'}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have jsp using struts bean tag library: <html> <head> <meta http-equiv=Content-Type content=text/html; charset=UTF-8>
I have inherited some code that isn't quite working ... I have jsp which
I have a JSF Portlet which has user form in the view JSP. The
I'm trying to override a JSP in Liferay 6.1, namely html/portlet/enterprise_admin/settings/authentication.jsp. I have created
I have a jsp that contains a table with some information from db. I
I have a jsp page, which imports another jsp. This import is wrapped into
I have a JSP java application that has a name AAA-master so currently my
I have a jsp file: validate.jsp- var rollNo=document.forms[result_form][studentRollno].value; var name=document.forms[result_form][studentName].value; $(#student_result).load(result.jsp?rollNo=+rollNo+&name=+name); As you can
I have a JSP custom Tag <ex:UndorderdList list=<%= MenuItems%>></ex:UndorderdList> which finally creates unordered list
I have a JSP application that connects to oracle on the log in page.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.