6 Replies Latest reply on Jan 16, 2011 4:01 PM by chris49324

    Disable validation on tab change with RichFaces 4.x

    chris49324 Newbie

      hi,

      I want to disable validation of the selected tab when I change tabs. I have different forms in each tab and everytime I want to change the tab, the selected tab's form gets validated, validation errors occour and so the tab isn't changed.

      In another post, the solution to this problem was to remove the enclosing form of the tabPanel, unfortunately this doesn't work anymore. When i remove the parent form I get this exception:

       

      SCHWERWIEGEND: Error Rendering View[/index.xhtml]
      org.richfaces.renderkit.util.EnclosingFormRequiredException: class org.richfaces.component.html.HtmlTabPanel (id="tabPanel") did not find parent form.
              at org.richfaces.renderkit.util.FormUtil.throwEnclFormReqExceptionIfNeed(FormUtil.java:47)
              at org.richfaces.renderkit.html.TogglePanelRenderer.doEncodeBegin(TogglePanelRenderer.java:109)
              at org.richfaces.renderkit.html.TabPanelRenderer.doEncodeBegin(TabPanelRenderer.java:80)
              at org.richfaces.renderkit.RendererBase.encodeBegin(RendererBase.java:116)
              at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:823)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1611)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
              at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380)
              at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
              at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
              at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
              at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
              at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
              at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
              at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
              at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
              at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
              at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
              at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
              at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
              at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
              at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
              at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
              at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
              at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
              at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
              at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
              at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
              at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
              at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
              at java.lang.Thread.run(Thread.java:619)
      
      WARNING: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
      org.richfaces.renderkit.util.EnclosingFormRequiredException: class org.richfaces.component.html.HtmlTabPanel (id="tabPanel") did not find parent form.
              at org.richfaces.renderkit.util.FormUtil.throwEnclFormReqExceptionIfNeed(FormUtil.java:47)
              at org.richfaces.renderkit.html.TogglePanelRenderer.doEncodeBegin(TogglePanelRenderer.java:109)
              at org.richfaces.renderkit.html.TabPanelRenderer.doEncodeBegin(TabPanelRenderer.java:80)
              at org.richfaces.renderkit.RendererBase.encodeBegin(RendererBase.java:116)
              at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:823)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1611)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
              at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380)
              at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
              at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
              at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
              at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
              at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
              at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
              at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
              at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
              at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
              at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
              at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
              at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
              at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
              at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
              at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
              at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
              at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
              at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
              at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
              at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
              at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
              at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
              at java.lang.Thread.run(Thread.java:619)
      
        • 1. Disable validation on tab change with RichFaces 4.x
          Ilya Sorokoumov Master

          I guess you should set immediate attribute for rich:tabPanel to true.

          • 3. Disable validation on tab change with RichFaces 4.x
            Ilya Sorokoumov Master

            Could you post a sample of your code?

            B.t.w. what switchType are you using?

            • 4. Re: Disable validation on tab change with RichFaces 4.x
              chris49324 Newbie

                   <h:form>
                      <rich:tabPanel id="tabPanel" switchType="server" rendered="#{!userBean.loggedIn}">
                              <rich:tab id="signinTab" >
                                  <f:facet name="header">
                                      <h:outputText value="#{userMsg.signin}"/>
                                  </f:facet>            
                                  <h:form>
                                      <h:panelGrid columns="2" styleClass="loginPanel">
                                          <h:commandButton value="#{userMsg.signin}" action="#{loginForm.login}" />
                                      </h:panelGrid>
                                  </h:form>
                              </rich:tab>
                              <rich:tab id="signupTab">
                                  <f:facet name="header">
                                      <h:outputText value="#{userMsg.signup}"/>
                                  </f:facet>
                                  <h:form>
                                      <h:panelGrid columns="2">
                                          <h:commandButton value="#{userMsg.signup}" action="#{signupForm.signup}" />
                                      </h:panelGrid>
                                  </h:form>
                              </rich:tab>
                              <rich:tab>
                                  <f:facet name="header">
                                      <h:outputText value="#{userMsg.reset}"/>
                                  </f:facet>
                                  <h:form>
                                      <h:panelGrid columns="2">
                                          <h:commandButton value="#{userMsg.reset}" action="->/index.xhtml"/>
                                      </h:panelGrid>
                                  </h:form>
                              </rich:tab>
                          </rich:tabPanel>
                      </h:form>
              
              • 5. Disable validation on tab change with RichFaces 4.x
                Ilya Sorokoumov Master

                1) Try set switchType to client and move your forms inside tabs. But unfortunatly I'm not sure that It will help you.

                2) I still think that immediate attribute should work in your case so that probably it's a bug in RF 4.0. What version of RF 4.0 are you using?

                • 6. Re: Disable validation on tab change with RichFaces 4.x
                  chris49324 Newbie

                  I use switch type Server because it restores the selected tab, with the client switch type you will always get the first tab selected after submitting a form. Sure I could save the selected Tab in a managed Bean, but I don't really want to do that.

                   

                  I researched the immediate attribute a bit, but answers are very inconsistent. Some say it skips validation, some say it doesn't. I am using Hibernate validation btw. But that shouldn't make a difference.

                   

                  My Richfaces version: 4.0.0.20101226-M5