4 Replies Latest reply on May 6, 2009 11:10 AM by khalid Horri

    Can't submit the form

    khalid Horri Newbie

      Hello
      I can't submit the form, and I got this error:


      15:02:05,284 INFO  [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
      sourceId=j_id15:directory[severity=(ERROR 2), summary=(La valeur nest pas valide.), detail=(La valeur nest pas valide.)]
      sourceId=j_id15:theme[severity=(ERROR 2), summary=(La valeur nest pas valide.), detail=(La valeur nest pas valide.)]



      the page adddocument.xhtml is like this:


      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
          xmlns:s="http://jboss.com/products/seam/taglib"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:rich="http://richfaces.org/rich"
          xmlns:a4j="http://richfaces.org/a4j"
          template="layout/template.xhtml">
      
                <ui:define name="body">
      
          <h:form>
      
              <rich:panel>
                  <f:facet name="header">Ajouter un nouveau document</f:facet>
      
      
                  <div class="dialog">
                      <h:panelGrid columns="2" rowClasses="prop" columnClasses="name,value">
                          <h:outputLabel for="title">Titre</h:outputLabel>
                          <h:inputText id="title"
                                    value="#{document.title}"/>
                                  
                          <h:outputLabel for="ref">reference</h:outputLabel>
                          <h:inputText id="ref"
                                      value="#{document.ref}"/>
                          
                          <h:outputLabel for="summary">resume</h:outputLabel>
                          <h:inputTextarea id="summary"
                                      value="#{document.summary}"/>
                                      <h:outputLabel for="theme">theme</h:outputLabel>
                          <h:selectOneMenu id="theme" 
                                      value="#{document.theme}">
                                      <s:convertEntity />
                              <s:selectItems value="#{themes}" 
                                             var="theme"
                                             label="#{theme.themeName}"/>
                          </h:selectOneMenu>
                                      <h:outputLabel for="keyWords">Mot cle</h:outputLabel>
                          <h:inputText id="keyWords"
                                      value="#{document.keyWords}"/>
                          <h:outputLabel for="directory">repertoire</h:outputLabel>            
                          <h:selectOneMenu id="directory" 
                                      value="#{document.directory}">
                                      <s:convertEntity />
                              <s:selectItems value="#{directories}" 
                                             var="directory"
                                             label="#{directory.directoryName}"/>
                          </h:selectOneMenu>
                          <h:outputLabel for="directory">Document</h:outputLabel>
                           <rich:fileUpload fileUploadListener="#{fileUploadBean.listener}"
                      id="upload"
                      immediateUpload="#{fileUploadBean.autoUpload}"
                      allowFlash="#{fileUploadBean.useFlash}">
                      <a4j:support event="onuploadcomplete" reRender="info" />
                  </rich:fileUpload> 
                  
                      </h:panelGrid> 
                  </div>
      
                  
      
              </rich:panel>
      
              <div class="actionButtons">
                  <h:commandButton value="Ajouter" action="#{manageDocument.add}"/>
              </div>
      
          </h:form>
      
       </ui:define>
      </ui:composition>



      and the document entity is :


      @Entity
      @Name("document")
      @Scope(ScopeType.SESSION)
      @Table(name="documents")
      public class Document implements Serializable{
           
           /**
            * 
            */
           private static final long serialVersionUID = 12L;
           private int idDoc;
           private String title;
           private String ref;
           private String summary;
           private Theme theme;
           private String keyWords;
           private Directory directory;
           private String document;
           
           public Document() {
                super();
           }
           
           public Document(Directory directory, String document, int idDoc,String title,
                     String keyWords, String ref, String summary, Theme theme) {
                super();
                this.directory = directory;
                this.document = document;
                this.idDoc = idDoc;
                this.title = title;
                this.keyWords = keyWords;
                this.ref = ref;
                this.summary = summary;
                this.theme = theme;
           }
           /**
            * @return the idDoc
            */
           @Id
           @GeneratedValue
           @NotNull
           public int getIdDoc() {
                return idDoc;
           }
           /**
            * @param idDoc the idDoc to set
            */
           public void setIdDoc(int idDoc) {
                this.idDoc = idDoc;
           }
           
           /**
            * @return the name
            */
           @NotNull
           public String getTitle() {
                return title;
           }
      
           /**
            * @param name the name to set
            */
           public void setTitle(String title) {
                this.title = title;
           }
      
           /**
            * @return the ref
            */
           public String getRef() {
                return ref;
           }
           /**
            * @param ref the ref to set
            */
           public void setRef(String ref) {
                this.ref = ref;
           }
           /**
            * @return the summary
            */
           public String getSummary() {
                return summary;
           }
           /**
            * @param summary the summary to set
            */
           public void setSummary(String summary) {
                this.summary = summary;
           }
           /**
            * @return the theme
            */
           @ManyToOne()
           @JoinColumn(name="idTheme", referencedColumnName="idTheme")
           public Theme getTheme() {
                return theme;
           }
           /**
            * @param theme the theme to set
            */
           public void setTheme(Theme theme) {
                this.theme = theme;
           }
           /**
            * @return the keyWords
            */
           public String getKeyWords() {
                return keyWords;
           }
           /**
            * @param keyWords the keyWords to set
            */
           public void setKeyWords(String keyWords) {
                this.keyWords = keyWords;
           }
           /**
            * @return the directory
            */
           @ManyToOne()
           @JoinColumn(name="idDirectory", referencedColumnName="idDirectory")
           public Directory getDirectory() {
                return directory;
           }
           /**
            * @param directory the directory to set
            */
           public void setDirectory(Directory directory) {
                this.directory = directory;
           }
           /**
            * @return the document
            */
           public String getDocument() {
                return document;
           }
           /**
            * @param document the document to set
            */
           public void setDocument(String document) {
                this.document = document;
           }
           
           
      
      }
      


      please help me to get a solution


      regards HORRI




        • 1. Re: Can't submit the form
          Arbi Sookazian Master

          You need to post your backing bean as well.


          I'm not sure if it's ok to embed rich:panel inside h:form (try removing rich:panel tags).


          But your h:commandButton is inside h:form tags.


          So what exactly happens when you click the Ajouter (submit?) button?


          does the add method get called or not?


          if you're using a session bean as the backing bean then make sure the add() method is available in the local/remote interface.


          the following is not an error:


          15:02:05,284 INFO  [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
          sourceId=j_id15:directory[severity=(ERROR 2), summary=(La valeur nest pas valide.), detail=(La valeur nest pas valide.)]
          sourceId=j_id15:theme[severity=(ERROR 2), summary=(La valeur nest pas valide.), detail=(La valeur nest pas valide.)]



          You see this in the server.log and/or console when you do like facesMessages.add(...) and the message(s) don't display on the JSF, possibly b/c the h:message, for example, was not reRendered.


          I would use process of elimination (simplify your xhtml by removing tags, etc) to determine root-cause for add() method not firing...

          • 2. Re: Can't submit the form
            khalid Horri Newbie

            Thanx for reply Arbi,


            If I remove


            <h:selectOneMenu>


            the form is fired, so the problem is her, the seam can't convert data in jsf page to get Document or Theme object

            • 3. Re: Can't submit the form
              Nicklas Karlsson Master

              If you're not in a SMPC LRC, try implementing equals and hashcode on your entity.

              • 4. Re: Can't submit the form
                khalid Horri Newbie

                thanx for your reply


                I do it and now it work :)