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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:34:20+00:00 2026-05-31T13:34:20+00:00

I am having problems with ValueChangeListener attached to a dropdown list. Here is the

  • 0

I am having problems with ValueChangeListener attached to a dropdown list.

Here is the code:

<h:selectOneMenu 
value = "#{MultiFileSelectMgmtBean.selectedLocationName}" 
valueChangeListener = "#{MultiFileSelectMgmtBean.LocationChangeEvent}" 
onchange = "submit();" 
>

<f:selectItems 
value = "#{MultiFileSelectMgmtBean.locationsListItems}"> 
</f:selectItems>

</h:selectOneMenu>

And here is the backing bean:

protected List<SelectItem> locationsListItems;
...

public void LocationChangeEvent( ValueChangeEvent vce ) throws Exception
{
   selectedLocationName = (String) vce.getNewValue();
}

The problem is that ‘selectedLocationName’ gets a “11” or “13” value, even the dropdown list is populated with two strings “LocationTest1” and “LocationTest2”.

What could be the problem with vce.getNewValue?

  • 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-31T13:34:20+00:00Added an answer on May 31, 2026 at 1:34 pm

    The submitted value of the dropdown list is the option value, not the option label as you seem to think. Note that the method is also called getNewValue(), not getNewLabel(). The option labels are not sent over HTTP from client to server by the HTML form submit. There’s no way to extract them from the HTTP request.

    If you really need the option label instead of the option value for some unclear reason, then you’ll either need to use it instead of option value while creating the select items, or to have a mapping of all option labels associated with the option values somewhere, so that you can get the label by the value from this mapping. The chance is big is that you already have this sort of mapping in your bean, otherwise you wouldn’t be able to populate the <f:selectItems> value 🙂

    See also:

    • How to get both label and value from f:selectItems
    • Our <h:selectOneMenu> tag wiki page

    Unrelated to the concrete problem: the combination of a <h:selectOneMenu>, a valueChangeListener and onchange="submit()" indicates that you’re using a JSF 1.x specific hack in order to achieve the functional requirement of populating another dropdown or fields based on the change of the dropdown. Since you seem to be already using JSF 2.x, I recommend you to forget about this approach at all and just use <f:ajax listener> instead. The aforelinked wiki page contains one example.

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

Sidebar

Related Questions

I am having problems with simple adding text value to an associative array. Here's
im having problems with the following code: for (var i:Number=0; i<numFaces;i++){ var faceLoader:Loader =
Having problems with what should be a no brainer LC. Code snippet below: def
am having problems with some Regex code can anyone help. I have the following
I am having problems trying to POST a JSON Array. For my Android code,
I am having problems with the code below. Basically it's 2 parts in the
Having problems with assigning a specific id to a varied list of items selected
Am having problems with the following code reporting an 'invalid argument' in IE6. function
i having problems using this code in order to include a photo in my
Im having problems understanding the app logic to this password reset code i found

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.