1 Reply Latest reply on Nov 3, 2008 1:01 PM by utdrew

    How to change active tabs in tabPanel?

      Im very new to Richfaces and I'd like to know if someone can give me an example of how I can change the active tab in a tabPanel when the user hits a form button.
      For example, I'd like to have previous and next buttons inside the tab and when the user clicks on the next button the active tab changes to the next tab.


      Thank you for your help.

        • 1. Re: How to change active tabs in tabPanel?
          utdrew

          I hacked together this javascript to do it on the client side. The 'pane' argument needs to be the id of the tabpanel your tabs are in. Most of the code was stripped for the richfaces js library for tab panel

          function selectNextTab(pane){
           var labelSuffix = "_lbl";
           var cellSuffix = "_cell";
           var shiftedTableSuffix = "_shifted";
           var contentSuffix = "";
           var tabs = RichFaces.panelTabs[pane];
           var FF = RichFaces_FF_Loaded;
           if(tabs){
           var found=false;
           for( var i=0; i<tabs.length; i++){
          
           var tabi = tabs;
           var tabId = tabi.id;
           var tabElement = $(tabId + contentSuffix);
           var tabLabelId = tabId +labelSuffix;
           var tabLabel = $(tabLabelId);
          
           var shiftedTable = $(tabId + shiftedTableSuffix);
           if(found && tabElement) {
           if(RichFaces.onTabChange(null,pane,tabId)) {
           RichFaces.switchTab(pane,tabId,tabLabel);
           }
           break;
           }
           if (RichFaces.isTabActive(tabLabelId)) {
           if(tabElement) {
           found=true;
           }
           }
           }
           }
           }
          


          Drew