1 2 Previous Next 20 Replies Latest reply: May 15, 2012 8:09 AM by Demas Sinner RSS

    Value is not Valid with <s:entityConverter and equals and ha

    Franck MARTIN Newbie

      hi

      After submitting a form for saving a "Dossier", I'm getting the jsf validation error "value is not valid" for the value "Paiement" selected from a dropdown list .

      For that dropdown list i used the seam entity converter.

      i overrid the methods equals and hashcode for the entity (Paiement) that is to be displayed in the dropdownlist.

      i checked the html generated by seam for the dropdownlist and the values are correct. they match the primary key (Paiement.id)

      Any idea of what's going wrong? Below i copied some code to make it clearer.

      Dossier

      public class Dossiers implements java.io.Serializable {
      
       private Integer dosId;
      
      
      
       private Paiement paiement;
      
       @ManyToOne(fetch = FetchType.LAZY)
       @JoinColumn(name = "pai_id", nullable = false)
       @NotNull
       public Paiement getPaiement() {
       return this.paiement;
       }
      
       public void setPaiement(Paiement paiement) {
       this.paiement = paiement;
       }
      
      


      Paiement :
      @Override
       public boolean equals(Object obj) {
       if (!(obj != null && obj instanceof Paiement))
       return false;
       Paiement ct = (Paiement) obj;
       if (paiId.equals(ct.paiId))
       return true;
       return false;
       }
      
       @Override
       public int hashCode() {
       return paiId==null ? 0 : paiId.hashCode();
       }
      
      


      the view
      <h:selectOneMenu value="#{dossier.paiement}" id="paiement" layout="pageDirection" styleClass="radio" required="true" >
       <s:selectItems value="#{referential.listePaiements}" var="paiement" label="#{paiement.libelles[langUser].libLib}"/>
       <s:convertEntity/>
       </h:selectOneMenu>
      




        1 2 Previous Next