2 Replies Latest reply on Jun 26, 2013 3:02 AM by wrdlprmpft

    rich:tabPanel changing activeItem programmatically not working?

    wrdlprmpft

      Dear RF community,

       

      Since two days I am struggling with rich:tabPanel. I want to achieve, that when I have made a selection in one tab, tabPanel should automatically switch to another active item to display another tab with associated form (which worked in my previous JSF1.2 application). As I did not come to a working solution with the new version, I finally tried to reduce the application as far as possible. Now I am wondering whether I found a bug or am doing still something wrong.

      As you can see in the code below I have a tabPanel with three tabs. Each of them should hold an a4j:region with input fields, but now I have reduced it, so that any of them only contains a button, which calls a bean method to change the activeItem value activeItem="#{geographyBacking.displayTab}". Thus I would expect that when pressing a Tab2 button it would lead me to the second tab and with Tab3 to the third tab. Instead I always end up on the first tab after render!

      The logs are telling me that everything goes ok in the bean, just the jsf component does obviously not adapt the tabs to the activeItem. The behaviour is the same with switchType= server, ajax or client

       

       

      Here is the code:

       

      xhtml:

       

      <ui:component xmlns="http://www.w3.org/1999/xhtml"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:a4j="http://richfaces.org/a4j"
           xmlns:rich="http://richfaces.org/rich">
      
      
           <rich:panel>
      
                <f:facet name="header">Edit Geography</f:facet>
      
                <rich:tabPanel id="Geography" activeItem="#{geographyBacking.displayTab}" switchType="server">
      
                     <rich:tab header="Administrative Unit" id="selectCountryLocation">
      
                          <a4j:commandButton ajaxSingle="true" value="Tab2"
                               render="Geography"
                               action="#{geographyBacking.test2()}" />
      
                     </rich:tab>
      
                     <rich:tab header="Edit Site" id="editSite">
      
                          <a4j:commandButton ajaxSingle="true" value="Tab3"
                               render="Geography"
                               action="#{geographyBacking.test3()}" />
      
                     </rich:tab>
      
                     <rich:tab header="Interpreted Site Lists" id="interpretedSiteLists">
      
                          <a4j:commandButton ajaxSingle="true" value="Tab2"
                               render="Geography"
                               action="#{geographyBacking.test2()}" />
      
                     </rich:tab>
      
                </rich:tabPanel>
      
           </rich:panel>
      
      </ui:component>
      
      
      

       

      For completeness I also show the parent form (it should not be of influence

       

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:rich="http://richfaces.org/rich"
           xmlns:a4j="http://richfaces.org/a4j"
           template="/layout/testTemplate.xhtml">
      
           <ui:define name="body">
      
                <h:messages globalOnly="true" styleClass="message" id="globalMessages" />
      
                <rich:panel>
                     <h:form>
                          <f:facet name="header">Edit Site</f:facet>
                          <ui:include src="facelets/Geography.xhtml" />
                     </h:form>
                </rich:panel>
      
           </ui:define>
      
      </ui:composition>
      

       

      The relevant part of the backing bean:

       

       

      @Name("geographyBacking")
      @Scope(ScopeType.CONVERSATION)
      public class GeographyBacking extends CRUDBacking {
      
         @Logger
            Log log;
      
           private String displayTab;
      
           public String getDisplayTab() {
                log.info("getDisplayTab: " + displayTab + " this: " + this);
                return displayTab;
            }
      
            public void setDisplayTab(String displayTab) {
                log.info("setDisplayTab: " + displayTab + " this: " + this);
                this.displayTab = displayTab;
            }
      
           public void test2() {
                    displayTab = "editSite";
                    log.info("GeographyBacking.test: displayTab = " +  displayTab);
            }
          
           public void test3() {
                   displayTab = "interpretedSiteLists";
                  log.info("GeographyBacking.test: displayTab = " +  displayTab);
            }
      
      }
      

       

      Some of you may have noticed the application background is Seam 2.x (Seam 2.3.1.CR1). Richfaces is 4.3.2  and Mojarra 2.1.19. I am quite sure that it would have worked correctly with Richfaces 3.x / JSF 1.2.

       

      I would be grateful for any advice

       

      Kind regards and thanks in advance

       

      Chris