1 Reply Latest reply on May 7, 2008 12:07 PM by Joao Viragine

    Seam problem with SelectOneMenu

    Bertrand Le Newbie

      I think I've a big problem with understanding Seam.
      I'm trying to make a simple new user form, but I'm on the wrong way I think, because it doesn't work :

      I've a User entity class :

      @Table(name = "user", catalog = "mydb")
      public class User implements java.io.Serializable {
           private int uCode;
           private UserType userType;
           private String uFirstname;
           private String uLastname;
           private String uPhone;
           private String uEmail;
      then getters and setters...

      I've a UserType entity class :

      @Table(name = "usertype", catalog = "mydb")
      public class UserType implements java.io.Serializable {
           private int utCode;
           private String utName;
      then getters and setters...

      I have also a Session bean which manages my page :

      public class UserBean implements IUser {
           User user;
           private List<User> users;
           EntityManager entityManager;
           public String add()

      and finally, here is my view :

      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
      <ui:define name="body">
          <h:messages globalOnly="true" styleClass="message"/>
          <f:facet name="header">#{messages.newcustomer}</f:facet>
          <p>#{messages.completethisform} :</p>
               <table border="0" width="600px">
                    <td>#{messages.lastname} :</td>
                    <td><h:inputText value="#{user.uLastname}" /></td>
                    <td>#{messages.firstname} :</td>
                    <td><h:inputText value="#{user.uFirstname}" /></td>
                    <td>#{messages.usertype} :</td>
                         <h:selectOneMenu value="#{user.userType}" >
                              <s:selectItems value="#{allusertypes}" var="type" label="#{type.utname}"  />
                              <s:convertEntity  />
                    <td>#{messages.email} :</td>
                    <td><h:inputText value="#{utilisateur.utemail}" /></td>
                    <td>#{messages.phone} :</td>
                    <td><h:inputText value="#{user.uPhone}" /></td>
               <h:commandButton action="#{userBean.add}" value="Ok" type="submit"  ></h:commandButton>

      The main problem concerns the selectOneMenu, because I can't get the UserType value in my User Entity, and I have
      this kind of error in my Eclipse Console :

      INFO  [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
      sourceId=j_id49:j_id57[severity=(ERROR 2), summary=(j_id49:j_id57: Erreur de validation: Valeur not valid.), detail=(j_id49:j_id57: Erreur de validation: Valeur not valid.)]

      Could someone help me please ?