3 Replies Latest reply on Jun 26, 2012 10:24 AM by stevestair

    Bug in rich:tabPanel tab switching?

    stevestair

      I've got the simplest possible tabPanel and a submit button, like this

      <body>
          <h:form>
              <rich:tabPanel switchType="ajax" selectedTab="#{TestBean.selectedTab}">
                  <rich:tab name="One" label="One" />
                  <rich:tab name="Two" label="Two" />
              </rich:tabPanel>
              <a4j:commandButton value="Submit" disabled="#{TestBean.submitDisabled}" />
          </h:form>
      </body>
      

      and a simple backing bean

      package test;
      
      public class TestBeanModel {
      
          private String selectedTab;
      
          public String getSelectedTab() {
              return selectedTab;
          }
      
          public void setSelectedTab(String selectedTab) {
              System.out.println("setSelectedTab(" + selectedTab + ")");
              this.selectedTab = selectedTab;
          }
      
          public boolean isSubmitDisabled() {
              System.out.println("isSubmitDisabled()");
              return true;
          }
      }
      

       

      Every time I switch tabs, I see output like this:

      isSubmitDisabled()
      setSelectedTab(Two)
      

       

      I'm assuming that it is rerendering the submit button, and therefore calling the isSubmitDisabled() method.  Why?

       

      I tried adding ajaxSingle="true" to the tabPanel, but it doesn't make any difference.  I can of course change the switchType to client, but then the server can't tell which tab is selected.

      I saw a post here that, instead of just using switchType="ajax", used "client", and called an <a4j:jsFunction> ontabchange (https://community.jboss.org/message/550099#550099).

      I didn't see any reason why this is different than using switchType="ajax", until I added ajaxSingle="true" to the jsFunction.

       

      <body>
          <h:form>
              <a4j:jsFunction id="tabChangeFn" name="tabChangeFn" ajaxSingle="true">
                  <a4j:actionparam name="name" value="name" assignTo="#{TestBean.selectedTab}" noEscape="true" />
              </a4j:jsFunction>
      
              <rich:tabPanel switchType="client" selectedTab="#{TestBean.selectedTab}"
                  ontabchange="tabChangeFn(event.enteredTabName)">
                  <rich:tab name="One" label="One" />
                  <rich:tab name="Two" label="Two" />
              </rich:tabPanel>
              <a4j:commandButton value="Submit" disabled="#{TestBean.submitDisabled}" />
          </h:form>
      </body>
      

       

      With that change, my tab changes only call setSelectedTab(), as I needed.   Am I missing something?

       

      I'm using RichFaces 3.3.2.SR1