4 Replies Latest reply on Nov 9, 2007 6:21 PM by jacob.orshalick

    Losing web page state on validation error with HibernateEnti

    jcelano

      I am using Seam 2.0 CR4 with Jboss 4.2 and Hibernate and my applications is deployed as a WAR.

      I have a simple page (startPage.xhtml) that links to another page (userInfo.xhtml) that is backed by a HibernateEntityHome object (UserHome.java). When i first navigate to the userInfo page, all works as desired. The user information is loaded and it appears that the entity is managed (e.g. the update button is displayed, not the add button).

      My problem is this, if there is a validation error (e.g. phone number not the correct format), then it appears that the entity is not managed anymore (e.g. the add button is displayed instead of the update button). What am i doing wrong?

      Any help would be appreciated. If you need more information or code, please let me know.

      Pages.xml snip...

       <page view-id="/userinfo.xhtml" login-required="true">
       <param name="id" value="#{userHome.id}"/>
       <navigation>
       <rule if-outcome="created">....</rule>
       </navigation>
       </page>
      


      Link snip....
      <h:outputLink value="userinfo.seam">
       <f:param value="#{user.id}" name="id"></f:param>
       User - Edit Current User
      </h:outputLink>
      


      UserInfoHome.java snip....

       @RequestParameter
       protected Integer id;
       public Integer getId() {
       log.info("getId() called id={0}", id);
       return id;
       }
      
      
       public void setId(Integer netkeyEntityId) {
       log.info("setId() called id={0}, netkeyEntityId={1}", id, netkeyEntityId);
       id = netkeyEntityId;
       }
      


        • 1. Re: Losing web page state on validation error with Hibernate
          pmuir

          1)Why are you using an h:outputLink not a s:link?
          2) Where do you start the long running conversation?

          • 2. Re: Losing web page state on validation error with Hibernate
            jcelano

            sorry it took me so long to reply....

            1) I tried using an s:link, with the same results, code is below

            <s:link view="/userinfo.seam" value="User - Edit Current User"
             <f:param value="#{user.id}" name="id"></f:param>
            </s:link>
            

            2) Not sure why i would need a long running conversation (unless i am completely missing something). The scope is relatively small...the page is displayed, the validation fails on the page. It seems to me that the validation failure should return the page as a managed page, but then again, i could be completely off base.

            Joe C

            • 3. Re: Losing web page state on validation error with Hibernate
              dustismo

              I think your problem is that you are using userinfo.seam instead of userinfo.xhtml

              • 4. Re: Losing web page state on validation error with Hibernate

                 

                "jcelano@netkey.com" wrote:
                2) Not sure why i would need a long running conversation (unless i am completely missing something). The scope is relatively small...the page is displayed, the validation fails on the page. It seems to me that the validation failure should return the page as a managed page, but then again, i could be completely off base.


                If you want to maintain state between requests you will have to begin a long-running conversation. A temporary conversation only lasts for the scope of a request. In other words, all state is lost at the end of the request (when the response is rendered) unless you specify to promote the conversation to long-running.