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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:07:52+00:00 2026-05-29T11:07:52+00:00

Other than c:if or c:choose , are there any better ways to implement conditional

  • 0

Other than c:if or c:choose, are there any better ways to implement conditional rendering of 1 component out of several components. Something like switch case for JSF pages?

  • 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-29T11:07:53+00:00Added an answer on May 29, 2026 at 11:07 am

    The canonical JSF approach for this is using the rendered attribute. Here are some examples:

    <h:someComponent rendered="#{bean.booleanValue}" />
    <h:someComponent rendered="#{bean.intValue gt 10}" />
    <h:someComponent rendered="#{bean.objectValue eq null}" />
    <h:someComponent rendered="#{bean.stringValue ne 'someValue'}" />
    <h:someComponent rendered="#{not empty bean.collectionValue}" />
    <h:someComponent rendered="#{not bean.booleanValue and bean.intValue ne 0}" />
    <h:someComponent rendered="#{bean.enumValue eq 'ONE' or bean.enumValue eq 'TWO'}" />
    

    The difference with JSTL tags is that the rendered attribute is evaluated during view render time, while JSTL tags are executed during view build time. See also JSTL in JSF2 Facelets… makes sense?

    So, if the variables which are necessary for evaluating the condition have a narrower scope than the view scope (i.e. request scope), then you should be using rendered attribute instead. For example, when re-rendering a group of components upon an ajax request. While the JSTL tags could work equally good in this case, they might be evaluated “too early” (i.e. before the action is invoked, which might in turn have changed the conditions) and they would also break the view scope. See also @ViewScoped breaks in tag handlers.

    If the variables necessary for evaluating the condition have a broader scope, e.g. session-wide or application-wide or are been hardcoded in some template client, then JSTL tags are more efficient as they will be evaluated during view build time only and not everytime during view render time. See also How to make a grid of JSF composite component?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any reason why I should choose one of these over the other?
Other than pasting a WDSL in the tech spec, what are the recommended ways
Other than using raw XML, is there an easy way in .NET to open
Other than pencil & paper? I found freemind, the mapping tool very useful. Any
Other than perhaps enhanced readability for very simple patterns, why would someone choose to
In my applicaion which is going to support language other than English, is there
Other than self.class.send :method, args... , of course. I'd like to make a rather
Other than standard OO concepts, what are some other strategies that allow for producing
Other than for app launch shortcuts, which should only be provided by the O/S,
Other than the fact that ASP.NET MVC Web Application has more clarity in its

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.