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

The Archive Base Latest Questions

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

I have a dataTable that lists some objects and I want to set a

  • 0

I have a dataTable that lists some objects and I want to set a property for those objects using a selectOneListbox. This is my dataTable

<h:dataTable value="#{someHandler.entities}"
                binding="#{someHandler.dataTable}" var="entitiy">
               <h:column>
                    <f:facet name="header">
                        <t:outputText value="Level" />
                    </f:facet>
                    <h:selectOneListbox id="level" value="#{entitiy.level}" size="1"
                        valueChangeListener="#{someHandler.changeLevel}"
                        onchange="submit()">
                        <f:selectItem itemValue="-" itemLabel="-" />
                        <f:selectItem itemValue="ALL" itemLabel="ALL" />
                        (and so on)
                    </h:selectOneListbox>
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <t:outputText value="Name" />
                    </f:facet>
                    <h:outputText value="#{entitiy.name}" />
                </h:column>
</h:dataTable>

The valueChangeListener looks like this:

public void changeLevel(ValueChangeEvent event) {
    String newLevel = (String) event.getNewValue();
    Logger logger = (Logger) dataTable.getRowData();        
    logger.setLevel(Level.toLevel(newLevel));
}

(dataTable is an HtmlDataTable object.)

However, the event object is always the same – no matter which row the selectOneListbox was in. (It seems always the logger in the first row). The Logger object I get is also not the one I want.

Any ideas? Thank you!

And anothers questions? Is the entitiy.setLevel() method called even though I have a valueChangeListener? I use entitiy.level because I want to show the chosen level as a default for those entity.

Thank you!

  • 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-22T01:44:13+00:00Added an answer on May 22, 2026 at 1:44 am

    There are two potential problems here:


    First, the onchange="submit()" submits the entire form. The valueChangeListener will be invoked on all input elements of which the submitted value differs from the initial value.

    You need to preset the value behind #{entitiy.level} with the same value as the default menu option. E.g. in the constructor.

    public Entity() {
        level = "-";
    }
    

    Or, better, make the default value null.

    <f:selectItem itemValue="#{null}" itemLabel="-" />
    

    so that the valueChangeListener won’t be invoked when the particular menu is not changed.

    Or, when you are already on JSF 2.x (please always mention exact JSF impl/version in your JSF questions), you can use <f:ajax> tag for this without the need for a valueChangeListener with a hacky onchange="submit()".


    Second, you need to ensure that the datatable value #{someHandler.entities} returns exactly the same list during the submit as it was during the initial request. So, do the data loading in the bean (post)constructor. In JSF 2.x you’d like to put the bean in the view scope as well.


    Unrelated to the concrete problem, you can also just use <h:selectOneMenu> instead of a <h:selectOneListbox size="1">.

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

Sidebar

Related Questions

I have a DataTable that I manually created and loaded with data using C#.
Ok. So I am pretty new a this. I have a datatable that I
I have 3 collection datatable that shows in this below Month: January ID NAME
I have a untyped DataTable that looks like this (srcTbl): date col_1 col_2 ...
This is tricky to explain. We have a DataTable that contains a user configurable
I have a list of objects that I return using webservice. And I try
I'm currently working on an app using MVVM that needs to have some data
If you have a DataTable that has a column of some Enum type. And
I have some designer generated code that I am using to query a dataset.
I have a DataTable that queries out something like below usergroupid...userid......username 1.............1...........John 1.............2...........Lisa 2.............3...........Nathan

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.