2 Replies Latest reply on Aug 17, 2010 3:47 PM by Todd Brady

    Reset Form Validation on return to page

    Todd Brady Newbie
      I have a page for users to change their profile information.  I have several fields required with required="true" and when they click submit the errors show just fine.  But when the user leaves the page and enters it again, the validation errors are still present.  Is there a way to clear the form validation when showing the page on a new request?

      pages.xml:
      <page view-id="/myProfile.xhtml" login-required="false">
           <action execute="#{myProfileAction.loadMyProfile}"/>
      </page>

      backing bean:
      @Out(required = false, scope=ScopeType.PAGE) Registration registration;
      @Begin(join = true)
      public void loadMyProfile() {
                try {
                     if (null != user.getUserId()) {
                          if (!isPostBack()) {
                          
                               registration = RegistrationDao.readUser(user.getUserId());
                                                        
                               // assign the current instance to tmpRegistration
                               Registration tmpRegistration = this.getInstance();
                                                   }
                     } else {
                          Messenger.error(Messages.ERROR_LOADING_USER_PROFILE);
                     }
                } catch (Exception ex) {
                     Messenger.error(Messages.ERROR_LOADING_USER_PROFILE);
                     AppLog.logFatal("Exception in loadMyProfile(): ", ex);
                }
           }   


      Somehow I want to start with a fresh view on a new request.
        • 1. Re: Reset Form Validation on return to page
          Todd Brady Newbie

          A little more information:
          I am using jboss-portal-2.7.0, seam 2.2.1, richfaces 3.3.3


          I want to be able to click the tab links and start a new view instance on these links if possible.  Thanks

          • 2. Re: Reset Form Validation on return to page
            Todd Brady Newbie
            Ok, still working through this issue.  If I create a link inside the xhtml file and redcirect it works:
            profile.xhtml

              <s:link id="configureUser" action="#{profileAction.configureUser}" >
                     <h:graphicImage value="#{sessionManager.imagePath}/wrench.png" />
              </s:link>

            ProfileAction.java
            @Begin (join = true)
                    public String configureUser() {
                            return "/myProfile.xhtml";
                    }

            This gets me a new view with no validation errors.  But I want to be able to click on a tab from the portal and accomplish this too.  From the default tabs.jsp in the jboss portal server:
            <ul>
                     <%
                        for (Iterator j = tmp.iterator(); j.hasNext();)
                        {
                           PortalNode childChild = (PortalNode)j.next();
                     %>
                     <li><a href='<%= childChild.createURL(context) %>'><%= childChild.getDisplayName(locale) %>
                     </a></li>
                     <%
                        }
                     %>
                 </ul>

            Has anyone tried to do this before?  The link in the tab is: /portal/auth/user/myProfile and I want that to create a new view.