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

  • Home
  • SEARCH
  • 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 5980689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:50:12+00:00 2026-05-22T21:50:12+00:00

I have a table where one of it’s columns contains a dropdown list (HtmlSelectItems

  • 0

I have a table where one of it’s columns contains a dropdown list (HtmlSelectItems component).
For any given row in this table, I want to be able to show or hide the dropdown at runtime, based on specific application conditions.

My solution in this case was to use the component’s pre-render event listener mechanism provided by JSF2.0 implementation. Basically in the JSF page I assigned an id to the HtmlSelectItems component (living inside a h:column) and set it with a pre render f:event element.
The f:event is pointing to one of my methods which receives the component id and process it.

My issue is that the HtmlSelectItems instance is SHARED between all the table rows, and if say I call HtmlSelectItems.setRender(false) on one dropdown list component, all the subsequent rows will stop displaying the drop downs. In fact the f:event pre render listener will stop getting called once the first setRender(false) is called on a dropdown

I can understand the fact that sharing one HtmlSelectItems instance between the table rows
has a positive impact on performance overall, but shouldn’t this component instance be re-initialized on each row?

Thanks a lot for any clarifications in this regard.

  • 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-22T21:50:13+00:00Added an answer on May 22, 2026 at 9:50 pm

    You need to let the rendered condition depend on the row itself, not on the parent bean.

    E.g.

    <h:dataTable value="#{bean.list}" var="item">
        <h:column>
            <h:selectOneMenu rendered="#{item.showDropdown}">
                ...
            </h:selectOneMenu>
        </h:column>
    </h:dataTable>
    

    instead of

    <h:dataTable value="#{bean.list}" var="item">
        <h:column>
            <h:selectOneMenu rendered="#{bean.showDropdown}">
                ...
            </h:selectOneMenu>
        </h:column>
    </h:dataTable>
    

    Or if it needs to be determined by the #{bean} rather than #{item} due to some design restrictions, then there are several ways.

    If you’re using DataModel as datatable’s value, then you can get the current row as follows:

    public boolean isShowDropdown() {
        Item item = model.getRowData();
        return shouldShowDropdown(item); // Do your thing.
    }
    

    If not, then maintain a Map<Long, Boolean> instead where the key is actually the identifier of the row item and the value represents whether the dropdown should be shown. This can then be used as follows:

    <h:dataTable value="#{bean.list}" var="item">
        <h:column>
            <h:selectOneMenu rendered="#{bean.showDropdown[item.id]}">
                ...
            </h:selectOneMenu>
        </h:column>
    </h:dataTable>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one table with 20 columns, I want only display this data on
I have table one which looks like this. And I want to get data
I have an html table where one of the columns contains <span> s with
I have one table orders with a foreing key ProductID. I want to show
I have a table where one column has duplicate records but other columns are
I have a SQL Mobile database with one table. It has several columns with
I have one table which display data as from Dynamic Content, I want to
i have one table sql server like below , from that table i want
I have one table that contain lots of records and I want to update
I have one table called: Transaction. This table has the following fields: (ID,ProductName,Amount,Date) placed

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.