1 Reply Latest reply: May 14, 2007 1:08 AM by Sergey Smirnov RSS

    Dynamically Changing selectedTab in TabPanel

    Alexander De Leon Newbie

      Hello,
      I haven't been able to figure out how to dynamically change the selected tab in a tabPanel. I have the following code:

      <a4j:commandButton value="Submit" action="#{myBean.search}"
       reRender="navigationTabs" />
      
      <rich:tabPanel id="navigationTabs" switchType="ajax" height="350"
       selectedTab="#{navigationBean.currentTab}" >
       <rich:tab name="tab1" label="Tab 1">
       <h:outputText value="You are in Tab 1" />
       </rich:tab>
       <rich:tab name="tab2" label="Tab 2">
       <h:outputText value="You are in Tab 2" />
       </rich:tab>
      </rich:tabPanel>
      


      My navigationBean has session scope and I change the String property currentTab from the action method that is called by the submit button. I set this property to the name of the tab I want to make active (i.e "tab1" or "tab2" )

      I notice that the tabPanel only calls getCurrentTab the first time is rendered, but not when the form is submitted or even when I refresh the page in the browser.

      Is there a way to change the selected tab from the server side ?

      I appreciate if you could help me.

      Thanks
      Alex