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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:54:32+00:00 2026-05-24T06:54:32+00:00

How can I specify a conditional rendering for an <f:selectItem> tag. I need to

  • 0

How can I specify a conditional rendering for an <f:selectItem> tag.
I need to display <f:selectItem> options according to a specific user’s status.

For example, I wanted something like:

<f:selectItem itemLabel="Yes! I need a girlfriend!"
             rendered="false(or some boolean condition)"
             itemValue="o1"/>
  • 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-24T06:54:32+00:00Added an answer on May 24, 2026 at 6:54 am

    The <f:selectItem> does not support the rendered attribute. Your closest bet is the itemDisabled attribute which still displays the item, but makes it unselectable. This is also supported in <f:selectItems>.

    In case of <p:selectOneMenu> you can then just add some CSS to hide disabled items.

    <p:selectOneMenu ... panelStyleClass="hideDisabled">
        <f:selectItem itemValue="1" itemLabel="one" />
        <f:selectItem itemValue="2" itemLabel="two" itemDisabled="#{some.condition}" />
        <f:selectItem itemValue="3" itemLabel="three" />
    </p:selectOneMenu>
    
    .ui-selectonemenu-panel.hideDisabled .ui-selectonemenu-item.ui-state-disabled {
        display: none;
    }
    

    In case of <h:selectOneMenu> you’re more dependent on whether the webbrowser supports hiding the disabled options via CSS:

    <h:selectOneMenu ... styleClass="hideDisabled">
        <f:selectItem itemValue="1" itemLabel="one" />
        <f:selectItem itemValue="2" itemLabel="two" itemDisabled="#{some.condition}" />
        <f:selectItem itemValue="3" itemLabel="three" />
    </h:selectOneMenu>
    
    select.hideDisabled option[disabled] {
        display: none;
    }
    

    The server side alternative is to bring in a JSTL <c:if> around the individual <f:selectItem> to contitionally add it to the view like this (make sure you’re aware of how JSTL works in JSF: JSTL in JSF2 Facelets… makes sense?):

    <f:selectItem itemValue="1" itemLabel="one" />
    <c:if test="#{not some.condition}">
        <f:selectItem itemValue="2" itemLabel="two"  />
    </c:if>
    <f:selectItem itemValue="3" itemLabel="three" />
    

    Or, you could simply dynamically populate a List<SelectItem> in the backing bean based on the calculated conditions and bind it with <f:selectItems>.

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

Sidebar

Related Questions

in a java webstart file (jnlp) you can specify the nativelib tag to load
When using Ninjects ConstructorArgument you can specify the exact value to inject to specific
I want to be able to specify user specific conditions in a MAX() sql
I know I can specify one for each form, or for the root form
In Subversion you can specify a range of versions to get an aggregate view
I understand that I can specify system properties to Tomcat by passing arguments with
I know you can specify fieldsets in django for Admin helpers. However, I cannot
In code one can specify globally accessible constants/enums/etc once that can then be reused
Normally we can specify a target in the link or use javascript window.open to
Is there any way I can specify a standard or custom numeric format string

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.