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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:40:54+00:00 2026-06-04T06:40:54+00:00

I implemented code that allows me to display a dropdown which depends on another.

  • 0

I implemented code that allows me to display a dropdown which depends on another. Everything works fine except when I try to retrieve and display the value of the two fields, it raises the following error:

form:parcours : erreur : de validation. la valeur est incrorrecte

in english :

form:parcours : validation error. value is not valid

I am using JSF 2.0, EJB 3.0, JPA 2.0 and PrimeFaces 3.2.

View:

    <h:form id="form" >

<!-- <p:growl id="msgs" showDetail="true"/> -->
<h:messages globalOnly="true"/>
<p:growl   id="msgs" showDetail="true" />


<p:panel header="Double Combo" style="margin-bottom:10px;">
    <h:panelGrid columns="2" cellpadding="5">

        <p:selectOneMenu id="countries" value="#{plansEtude.selectedDep}">
            <f:selectItem itemLabel="Select Country" itemValue="" />
            <f:selectItems value="#{plansEtude.depList}" var="c" itemLabel="#{c.nomDepFr}" itemValue="#{c.id}"/>
            <p:ajax update="parcours,parcoursTab"
                    listener="#{plansEtude.handleDepChange}" />
        </p:selectOneMenu>
        <p:selectOneMenu id="parcours" value="#{plansEtude.selectedParcours}" >
            <f:convertNumber maxFractionDigits="0"/>
            <f:selectItem itemLabel="Select City" itemValue="" />
            <f:selectItems value="#{plansEtude.parcoursList}" var="ct" itemLabel="#{ct.designParcours}" itemValue="#{ct.id}"   />

        </p:selectOneMenu>

    </h:panelGrid>
    <p:separator />

        <p:commandButton value="Submit" update="msgs" actionListener="#{plansEtude.displayLocation}" id="btnSubmit"/>

    </p:panel>

Controller :

@EJB
private DepartementFacade departementFacade;
@EJB
private ParcoursFacade parcoursFacade;
private List<Departement> depList;
private List<Parcours> parcoursList;
private Integer selectedDep;
private Integer selectedParcours;


public PlansEtude() {
}

public DepartementFacade getDepartementFacade() {
    return departementFacade;
}

public void setDepartementFacade(DepartementFacade departementFacade) {
    this.departementFacade = departementFacade;
}

public ParcoursFacade getParcoursFacade() {
    return parcoursFacade;
}

public void setParcoursFacade(ParcoursFacade parcoursFacade) {
    this.parcoursFacade = parcoursFacade;
}

public List<Departement> getDepList() {
    depList = getDepartementFacade().findAll();
    return depList;
}

public void setDepList(List<Departement> depList) {

    this.depList = depList;
}

public List<Parcours> getParcoursList() {
    return parcoursList;
}

public void setParcoursList(List<Parcours> parcoursList) {
    this.parcoursList = parcoursList;
}

public Integer getSelectedDep() {
    return selectedDep;
}

public void setSelectedDep(Integer selectedDep) {
    this.selectedDep = selectedDep;
}

public Integer getSelectedParcours() {
    return selectedParcours;
}

public void setSelectedParcours(Integer selectedParcours) {
    this.selectedParcours = selectedParcours;
}

public void handleDepChange(){
     if(selectedDep !=null && !selectedDep.equals(""))  

       parcoursList = parcoursFacade.findParcoursInDep(selectedDep);  
   else  
        parcoursList = new ArrayList<Parcours>();

}

public void handleParcoursChange(){

}

public void displayLocation() {  
    String monMessage="Departement :" + selectedDep + ", Parcours : " + selectedParcours;
    FacesMessage msg = new FacesMessage("Selected", monMessage);  

    FacesContext.getCurrentInstance().addMessage(null, msg);  
}

}

parcoursFacade :

 public List<Parcours> findParcoursInDep(Integer dep){
    Query query = em.createNamedQuery("Parcours.findParcoursInDep");
    query.setParameter("dep", dep);
    return (List<Parcours>)query.getResultList();
}

Named query :

     @NamedQuery(name = "Parcours.findParcoursInDep", query = "SELECT p FROM Parcours p WHERE p.departementid.id = :dep"),
  • 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-04T06:40:56+00:00Added an answer on June 4, 2026 at 6:40 am

    Remove the <f:convertNumber maxFractionDigits="0"/> from your parcours dropdown. It makes no sense. It would only convert the number to BigDecimal while you need an Integer.

    Another possible cause is that the #{plansEtude.parcoursList} has incompatibly changed during the form submit because the managed bean is request scoped. You need to make sure that the managed bean is placed in at least the view scope, so that the parcoursList is preserved for the submit.

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

Sidebar

Related Questions

I implemented this Jquery show/hide code and everything works fine except that the box
I have the following code that works perfectly. It allows the user to 'like'
I was looking at code that implemented the ICloneable interface for one of the
I've implemented a TreeCellRenderer that returns a JCheckBox (simple code that the renderer extends
The .Net framework try-catch implementation only allows you to catch types which inherit off
We're using a third-party middleware product that allows us to write code in an
I have some code that I absolutely must implement using goto . For example,
I'm trying to implement webgl shadow mapping from an example code that already implements
In the code there exists exactly one type that implements IResourceConverter. That's what the
Given the code below, how would you create/implement SR.h so that it produces the

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.