5 Replies Latest reply on Feb 20, 2008 8:37 AM by boevink.boevinkp.xs4all.nl

    Seam-gen generating entities incorrect?

    boevink.boevinkp.xs4all.nl

      After using 'Generate Seam Entities' using existing entities, a lot of entityLists are created with search functionality.


      The generated search forms in the xhtml pages look like this:



          <h:form id="userSearch" styleClass="edit">
      
          
      
              <rich:simpleTogglePanel label="User search parameters" switchType="ajax">
      
              
      
                  <s:decorate template="/layout/display.xhtml">
      
                      <ui:define name="label">email</ui:define>
      
                      <h:inputText id="email" value="#{userList.user.email}"/>
      
                  </s:decorate>
      
      
                  <s:decorate template="/layout/display.xhtml">
      
                      <ui:define name="label">username</ui:define>
      
                      <h:inputText id="username" value="#{userList.user.username}"/>
      
                  </s:decorate>
      
      
              
      
              </rich:simpleTogglePanel>
      
              
      
              <div class="actionButtons">
      
                  <h:commandButton id="search" value="Search" action="/UserList.xhtml"/>
      
              </div>
      
              
      
          </h:form>
      
      



      The action attribute within the h:commandbutton tag however causes a double submit in my opinion since an commandButton will by default commit a form without the action attribute.
      Using Live HTTP headers with Firefox, this results in both a POST and a GET request to the same page (UserList.seam).
      This results in undesired behaviour since the search parameters are not committed to this 'second' action.
      In my opinion the action attribute should be removed from the h:commandButton.



      Besides that I'm not able to get the search functionality working on entities with Hibernate Validation tags (e.g. @Email). This causes the globalMessages to be filled with 'must be a well-formed email address' when searching on a partial e-mail address.

        • 1. Re: Seam-gen generating entities incorrect?
          gavin.king

          This is exactly how it is supposed to work. It's using post-then-redirect. The post submits the forum, validates the text input, etc. (Which is why it validated the email address.) Then, the redirect includes the search parameters in the URL, so that the results page can be bookmarked.


          You will see a lot of use of post-then-redirect in Seam examples and other good web applications that support bookmarking.

          • 2. Re: Seam-gen generating entities incorrect?
            boevink.boevinkp.xs4all.nl

            Gavin King wrote on Feb 18, 2008 02:25 PM:


            This is exactly how it is supposed to work. It's using post-then-redirect. The post submits the forum, validates the text input, etc. (Which is why it validated the email address.) Then, the redirect includes the search parameters in the URL, so that the results page can be bookmarked.

            You will see a lot of use of post-then-redirect in Seam examples and other good web applications that support bookmarking.


            Thanks for your reply.
            I came to this conclusion since I'm struggling with the validation part and at first look I thought this second redirect caused my problems.....


            How and where is the text input validated on a post submit?
            Since the email address is a search field, I don't want it to be validated!
            I thought I had to explicitly use the validate or validateAll tag to fire hibernate validation.
            Since I'm not using these tags I assumed that no validation should be triggered.

            • 3. Re: Seam-gen generating entities incorrect?
              gavin.king

              Since the email address is a search field, I don't want it to be validated! I thought I had to explicitly use the validate or validateAll tag to fire hibernate validation.

              The Hibernate Validator annotations are ignored during a JSF form submission unless you have an <s:validate/> or <s:validateAll/> in the form that is being submitted.

              • 4. Re: Seam-gen generating entities incorrect?
                boevink.boevinkp.xs4all.nl

                Gavin King wrote on Feb 18, 2008 03:49 PM:


                Since the email address is a search field, I don't want it to be validated! I thought I had to explicitly use the validate or validateAll tag to fire hibernate validation.

                The Hibernate Validator annotations are ignored during a JSF form submission unless you have an <s:validate/> or <s:validateAll/> in the form that is being submitted.


                I hoped so, but that does not work....
                I'm using the seam-gen generated views. And have no <s:validate/> or <s:validateAll/> in my form.
                My template does not have such a tag neither does my decoration template (display.xhtml).


                I'm using:



                • jboss-seam-2.0.1.GA

                • jboss-4.2.2.GA

                • jdk1.5


                • 5. Re: Seam-gen generating entities incorrect?
                  boevink.boevinkp.xs4all.nl

                  Turned out to be an issue with pages.xml and page parameters:
                  JBSEAM-1587