4 Replies Latest reply on Sep 13, 2010 1:57 PM by rohitram

    setSelectedTab problem

    vetalok

      Hello experts,
      there are a big (for me) problem with selectedTab() method.
      I have 5 tabs, the last is active:
      [img]http://vetalok.ho.com.ua/pics/2008-12-02_134752.jpg[/img]
      I'm closing each tab from left to the right clicking on "Close" button, expecting to activate the tab which is at the left (i.e after closing product.3 tab product.2 should be activated).
      The problem is that sometimes i have the following error:

      Dec 2, 2008 2:00:02 PM org.apache.catalina.core.ApplicationContext log
      INFO: Tabs:_id9: tab panel [@selectedTab=product.3] has no enabled or rendered tab with such name. Tab: product.filter will be used instead!
      

      My code of rich:tabPanel component:
      <rich:tabPanel id="Tabs"
       switchType="client"
       binding="#{nodeAndTabDemoBean.tabPanel}"
       immediate="true"
       <rich:tab
       name="product.filter" rendered="true">
       </rich:tab>
       <rich:tab rendered="#{nodeAndTabDemoBean.productTabsNum >0}"
       name="product.0">
       <f:facet name="label">
       <h:panelGrid columns="2">
       <h:outputText value="#{nodeAndTabDemoBean.list[0]}"/>
       <a4j:commandButton image="/images/close.gif"
       actionListener="#{nodeAndTabDemoBean.removeTab}"
       ignoreDupResponses="true"
       immediate="true"
       limitToList="true"
       reRender="Tabs"
       title="Close" />
       </h:panelGrid>
       </f:facet>
       </rich:tab>
      ...
      

      I'm activating tab using binded
      private HtmlTabPanel tabPanel = new HtmlTabPanel();
      tabPanel.setSelectedTab(name);
      //here selected tab works but
      //tab panel [@selectedTab=product.3] has no enabled or rendered tab //with such name. Tab: product.filter will be used instead!
      //sometimes is appearing
      

      Closed tab does not satisfy the render condition showed above and will not be rendered.
      I must use switchType=client for rich:tabPanel tag.

      One of the working solution is to use setSelectedTab() of the source tab from the actionEvent object (event.getParent().getTabPanel().setSelectedTab), but it is not suitable in my case, as I need to activate the tab using only the name of it.

      I have tried to use other swithTypes, such methods as encodeChildren() and selectedTab attribute of the rich:tabPanel tab but it does not work as I expected.

      The reason is that
      private HtmlTabPanel tabPanel = new HtmlTabPanel();
      tabPanel.setSelectedTab(name);
      

      is ignored while the tab panel is reRender-ed (render response phase)

      Any ideas?
      Thanks for attention!

        • 1. Re: setSelectedTab problem
          nbelaevski

          Hi,

          Most likely you are trying to activate tab (@selectedTab=product.3) that is not rendered or disabled in time of rendering. Tab panel selects the first one in this case.

          • 2. Re: setSelectedTab problem
            rohitram

            Hi ,

            I am also getting the same error but with different scenario.I have 3 tabs and initially 2 tabs are disabled(2,3) .If I click the next in first tab then the second tab is enabling but if I click next in 2nd tab then error

            tabPanel [@selectedTab =tab2] has no enabled or rendered tab with such name .Tab:tab1 will be used instead.

             

            Any help to get out of this problem appreciated.

            • 3. Re: setSelectedTab problem
              ilya_shaikovsky

              probably it's a scope issue.. your object which holds disablement states for tabs - should be session sscoped.

              • 4. Re: setSelectedTab problem
                rohitram

                Thank You.But the managed bean entry given in faces-config.xml I gave scope as session itself.