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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:40:20+00:00 2026-06-03T23:40:20+00:00

i want to get the value from . i tryed this code but it

  • 0

i want to get the value from . i tryed this code but it doesn’t work :

<h:form>
        <h:outputLabel value="départements : "/>
        <h:selectOneMenu value="#{departementController.selected.id}" onchange="submit()" immediate="true">
            <f:valueChangeListener type="Controller.Listener.DepartementValueListener"/>
            <f:selectItems value="#{departementController.itemsAvailableSelectOne}"/>
        </h:selectOneMenu>

        <h:outputLabel value="nouvelle valeur : "/>

        <h:inputText value="#{departementController.comboBox}" id="dep"/>
    </h:form>

the controller :

 //departement change listener
private String comboBox;

public String getComboBox() {
    return comboBox;
}

public void setComboBox(String comboBox) {
    this.comboBox = comboBox;
}

public void departementChangeListener(ValueChangeEvent e) {
    // Skip validation of non-immediate components and invocation of the submit() method.
    FacesContext.getCurrentInstance().renderResponse();
    this.comboBox = e.getNewValue().toString();}

sourceId=j_idt7:j_idt9[severity=(ERROR 2), summary=(j_idt7:j_idt9 : erreur de validation. La valeur est incorrecte.), detail=(j_idt7:j_idt9 : erreur de validation. La valeur est incorrecte.)]

  • 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-06-03T23:40:22+00:00Added an answer on June 3, 2026 at 11:40 pm

    You’ve after all 2 problems.

    First, the error “erreur de validation. La valeur est incorrecte” which is the French translation of “Validation Error: Value is not valid” means that the submitted value doesn’t equals() any one of the available items in <f:selectItems>. Your code is not complete enough to point out the root cause, but I guess that you’ve a List<Department> there in <f:selectItems value> and thus every item is Department, but you’re trying to set it as a String value of id instead of as Department. This is not right. You need to supply a converter between Department and String and use #{departementController.selected} instead.

    Something like this:

    <h:selectOneMenu value="#{bean.selectedDepartment}">
        <f:selectItems value="#{bean.availableDepartments}" />
    </h:selectOneMenu>
    

    with

    private Department selectedDepartment;
    private List<Department> availableDepartments;
    

    And a @FacesConverter which converts between Department and its unique String representation.

    Your second problem is that you seem to be focusing too much on JSF 1.x targeted examples as to populating another field on change of the dropdown. You’re using a rather clumsy/hacky JSF 1.x workaround for that. In JSF 2.x you can just use <f:ajax> for this.

    <h:selectOneMenu value="#{bean.selectedDepartment}">
        <f:selectItems value="#{bean.availableDepartments}" />
        <f:ajax listener="#{bean.changeDepartment}" render="inputId" />
    </h:selectOneMenu>
    <h:inputText id="inputId" value="#{bean.input}" />
    

    with

    public void changeDepartment() {
        input = selectedDepartment.getId();
    }
    

    See also:

    • Our selectonemenu wiki page
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to get the value of this td my code function check() {
I'm beginner in MVC3, and I want to get a value from an another
I want to get the CreateDate value from xml file the xml file is
Using Access 2003 I want to get a table value from the two databases
Possible Duplicate: Return value from thread I want to get the free memory of
i bascially want to get the value of a variable from the codebehind to
I want to get three highes values from my array, but it should be
why does this code not work for referencing a const from a class? Background:
I want to get random keys and their respective values from a Map. The
I want to get the query name and values to be displayed from a

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.