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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:47:07+00:00 2026-05-26T02:47:07+00:00

I have the following Dropdown list, which has a Event associated with it, when

  • 0

I have the following Dropdown list, which has a Event associated with it, when user select a value from this dropdown the rest of the dropdown lists along with a table are filled accordingly:

 <Td>
 <h:selectOneMenu id="combocarList" 
     value="#{customerBean.selectedcar}"
     styleClass="comboStyle"
     valueChangeListener="#{customerBean.loadothercombos}"
     onchange="document.forms[0].submit()"
 >
     <f:selectItem
    itemLabel="-----------Select--------------"
    itemValue="None" />
      <f:selectItems value="#{customerBean.carsList}" />
   </h:selectOneMenu>
  </Td>

i also have a h:commandButton as below:

<TD>
    <h:commandButton id="btnCheckVals" value="Submit"
    onclick="return checkSelectedVal(this);"
    ></h:commandButton>
 </TD>

When i click the “Submit” button, the Event associated with above dropdown is called and the javascript function is never called! is the the expected behaviour ? and if so how can i make it so the javascript function is called before the event is fired allowing to check if user has selected values from dropdowns.

  • 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-26T02:47:08+00:00Added an answer on May 26, 2026 at 2:47 am

    I’m not sure if you have read my answer on one of your previous questions. You never gave any feedback and you accepted another answer. I’ve already warned that this approach is a hacky way.

    You’re basically abusing the valueChangeListener here. Its sole purpose is to provide a point to have access to both the old and new value at the same moment so that you can if necessary take specific business actions, such as logging the both values.

    Using it with the sole purpose to “automagically” populate another component/element based on only the new value (you’re totally not interested in the old value) is a hack. If you’re already on JSF 2.0, I really strongly recommend the <f:ajax> approach as mentioned in the linked answer.

    Back to your concrete problem, you need to understand that the valueChangeListener will always be fired whenever the submitted value differs from the initial model value. This is irrespective of all that JavaScript assistance. The onchange="submit()" does not specifically trigger the listener, it just submits the entire form to the server. It just happens to take place when the enduser changes the dropdown, so a change is guaranteed, so the listener will be invoked in the server side.

    Your problem suggests that you haven’t inside the valueChangeListener set the model value with the submitted value and that you’re calling FacesContext#renderResponse(). This approach is almost the same as demonstrated in the 1st way of my linked answer, expect of the line which sets the submitted value as model value. Because you didn’t set it, any subsequent form submits will thus always fire the listener (because the submitted value is different from the model value!). Also, because the FacesContext#responseComplete() skips the invoke action phase, the action method is never called.

    Now, reread my linked answer once again how to implement it properly.

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

Sidebar

Related Questions

if i have a dropdown with the following html: <select id=myDropdown name=myDropdown> <option value=6>Six</option>
i have the following code which has some duplication private List<SelectListItem> GetDeskList(int deskId) {
I have a model which has a collection of users. I'm looping through this
I have a JComboBox which has a list of midi files, I wonder if
The scenario is I have got 2 dropdown list and a table in which
I have a form in an ASP.NET MVC project which has a select drop
not sure how to word this correctly.. so i have a view which has
I have a dropdownlist with following options: <asp:DropDownList ID=ddlTaxStatus runat=server OnPreRender=ddlContainerStatus_PreRender> <asp:ListItem Text=--Select-- Value=-1></asp:ListItem>
I have the following code that sets a cookie: string locale = ((DropDownList)this.LoginUser.FindControl(locale)).SelectedValue; HttpCookie
Consider the following HTML snippet. The desired effect is to have a dropdown be

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.