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 954885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:17:17+00:00 2026-05-16T00:17:17+00:00

I can access my variable stored in a backing bean from my JSF2 page,

  • 0

I can access my variable stored in a backing bean from my JSF2 page, so things like

<h:outputText value="#{myBean.myValue}"/>

work, and the value (which is an int btw.) prints okay.
However, when trying to use this value in conditional expressions within c:if and/or c:when tags it never equals anything… so:

<c:if test="#{myBean.myValue == 1}">
    <c:set var="myVar" value="true"/>
</c:if>

<c:choose>
    <c:when test="#{myBean.myValue > 1}">
        <c:set var="myVar" value="true"/>
    </c:when>
</c:choose>

or even

#{myBean.myValue eq '1'} 

or

#{myBean.myValue == '1'}

will never evaluate to true, even if the value is indeed 1 or >1.

Annoyingly the comparison works in the rendered attribute of a tag! So this:

<h:outputText value="whatever" rendered="#{myBean.myValue == 1}"/>

is fine!

What is going on?

UPDATE:

This works:

public int getMyValue() {
    return 1;
}

but this does not:

@Column(name = "orderstatus")
public int getOrderStatus() {
return orderStatus;
}

The int’s value is printed correctly, but 1 == 1 is false.

Are entity beans handled in a special way? Can I use them for displaying their value on the UI?

UPDATE2:

<h:outputText value="#{order.adcOrderStatus.orderStatus.class}"/>

prints java.lang.Integer.

UPDATE3:

Here is the full code:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:cc="http://java.sun.com/jsf/composite">
    <cc:interface>
        <cc:attribute name="orderStatus" required="true"/>
    </cc:interface>
    <cc:implementation>
        <c:choose>
            <c:when test="#{cc.attrs.orderStatus == 1}" >
                <c:set var="unknownStatus" value="false"/>
            </c:when>
            <c:when test="#{cc.attrs.orderStatus == 2}" >
                <c:set var="unknownStatus" value="false"/>
            </c:when>
            <c:when test="#{cc.attrs.orderStatus == 3}" >
                <c:set var="unknownStatus" value="false"/>
            </c:when>
            <c:when test="#{cc.attrs.orderStatus == 99}" >
                <c:set var="unknownStatus" value="false"/>
            </c:when>
            <c:otherwise>
                <c:set var="unknownStatus" value="true"/>
            </c:otherwise>
        </c:choose>
        <h:graphicImage url="#{resource['img/icons/flag_yellow.png']}" rendered="#{cc.attrs.orderStatus == 1}"/>
        <h:outputText value="Created" rendered="#{cc.attrs.orderStatus == 1}"/>
        <h:graphicImage url="#{resource['img/icons/flag_orange.png']}" rendered="#{cc.attrs.orderStatus == 2}"/>
        <h:outputText value="Stopped" rendered="#{cc.attrs.orderStatus == 2}"/>
        <h:graphicImage url="#{resource['img/icons/flag_green.png']}" rendered="#{cc.attrs.orderStatus == 3}"/>
        <h:outputText value="Active" rendered="#{cc.attrs.orderStatus == 3}"/>
        <h:graphicImage url="#{resource['img/icons/flag_red.png']}" rendered="#{cc.attrs.orderStatus == 99}"/>
        <h:outputText value="Failed" rendered="#{cc.attrs.orderStatus == 99}"/>
        <h:graphicImage url="#{resource['img/icons/question_mark.png']}" rendered="#{unknownStatus}"/>
        <h:outputText value="Unknown" rendered="#{unknownStatus}"/>
    </cc:implementation>
</html>

It works when called with an int value. But this doesn’t work:

    <p:dataTable value="#{cc.attrs.orders}" var="order">
        <p:column>
            <f:facet name="header">
                <h:outputText value="Status"/>
            </f:facet>
            <mytag:orderStatus orderStatus="#{order.adcOrderStatus.orderStatus}"/>
        </p:column>
    </p:dataTable>

This displays the correct value:

<h:outputText value="#{order.adcOrderStatus.orderStatus.class}"/>
  • 1 1 Answer
  • 0 Views
  • 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-16T00:17:18+00:00Added an answer on May 16, 2026 at 12:17 am

    Did you declare JSTL core taglib as follows?

    <html xmlns:c="http://java.sun.com/jsp/jstl/core">
    

    If not or incorrectly declared, they it simply won’t be parsed and end up plain vanilla in generated HTML output. You can confirm this by opening the page in browser, rightlicking it and choosing View Source. You should not see any JSTL tag in there.


    Update: as per your update, it’s related to the fact that JSTL runs during build time of the view and JSF during render time of the view. In your particular case, this all would fail if #{cc.attrs.orderStatus} only available during render time of the view. For example, when it represents the currently iterated item of an iterating component, such as <h:dataTable>.

    You’d better rewrite the composite component as follows to use the rendered attribute instead:

    <h:panelGroup rendered="#{cc.attrs.orderStatus == 1}">
        <h:graphicImage url="#{resource['img/icons/flag_yellow.png']}" /> Created
    </h:panelGroup>
    <h:panelGroup rendered="#{cc.attrs.orderStatus == 2}">
        <h:graphicImage url="#{resource['img/icons/flag_orange.png']}" /> Stopped
    </h:panelGroup>
    <h:panelGroup rendered="#{cc.attrs.orderStatus == 3}">
        <h:graphicImage url="#{resource['img/icons/flag_green.png']}" /> Active
    </h:panelGroup>
    <h:panelGroup rendered="#{cc.attrs.orderStatus == 99}">
        <h:graphicImage url="#{resource['img/icons/flag_red.png']}"  /> Failed
    </h:panelGroup>
    <h:panelGroup rendered="#{cc.attrs.orderStatus != 1 && cc.attrs.orderStatus != 2 && cc.attrs.orderStatus != 3 && cc.attrs.orderStatus != 99}">
        <h:graphicImage url="#{resource['img/icons/question_mark.png']}" /> Unknown
    </h:panelGroup>
    

    See also:

    • JSTL in JSF2 Facelets… makes sense?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way i can access the page object from within the global.asax
I've been raised to believe that if multiple threads can access a variable, then
In MySQL, I can create an access a session variable by using a single
I can access the database either from a .NET program (using ODBC) or through
I know you can access the Contact Store from the SDk, but is it
I'm making a program that can access data stored inside a class. So for
How can I access HTTP headers in Spring-ws endpoint? My code looks like this:
In PHP you can access characters of strings in a few different ways, one
Is there a way I can access (for printout) a list of sub +
does anyone know where on access 2007 a function where i can access my

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.