1 Reply Latest reply on Oct 14, 2009 8:24 AM by Sainath Nair

    Dynamic  switching and clearing the tab contents

    Sainath Nair Newbie
      Hi guys

      I am trying to switch from one tab to the other one by using ajax... 
      I have 2 tabs

      1.Grid View
      2.Edit View

      When I set "Edit View" tab as the default tab, the switching works fine , but when i set "Grid View " , it does not go the next tab..

      I also have a command link "Edit"  in the "Grid View" tab.. I want that , when i click on the link , it shound render the "Edit View" tab with the particular record in that tab..

      Also when i click on the tabs , it should clear the previous contents of the tabs...


      welcome.xhtml
      -----------------------------------------------------------------------
        <rich:tabPanel id="cityTabs" switchType="ajax"
              selectedTab="#{groupWelcomTabBean.selectedTab}">
              <rich:tab label="Grid View" id="cyGrid">
             <a4j:include  viewId="/CyGroupList.xhtml"/>          
        </rich:tab>
              <rich:tab label="Edit View" name="cyEdit">
                        <a4j:include  viewId="/CyGroupEdit.xhtml"/>
                       
                    </rich:tab>
            
          </rich:tabPanel>

      -------------------------------------------------------------------------

      CyGrouplist.xhtml


      --------------------------------------------------------------------------
      <rich:column styleClass="action">
                  <f:facet name="header">Action</f:facet>
                    
                             #{' '}
                             <s:link value="Edit">
                           <a4j:support event="onclick"
                       actionListener="#{groupWelcomTabBean.changeTab}"  reRender="cityTabs" />
                        <f:param name="cyGroupGrpSqlidentity"
                              value="#{_cyGroup.grpSqlidentity}"/>
               </s:link>
                 
                 
                   </rich:column>

      ---------------------------------------------------------------------------------

      groupWelcomeTabBean.java

      ---------------------------------------------------------------------------------

      public class GroupWelcomTabBean {


               private String currentTab = "cyEdit";
               public String getcurrentTab() {
                     return currentTab;
                }
                public void setcurrentTab(String currentTab) {
                     this.currentTab = currentTab;
                }
                private String selectedTab = "cyGrid";
               public String getSelectedTab() {
                     return selectedTab;
                }
                public void setSelectedTab(String selectedTab) {
                     this.selectedTab = selectedTab;
                }
                // getters and setters for city and selectedTab
               public void changeTab (ActionEvent event){
                    
                          selectedTab = currentTab;
               }
           
      }

      -----------------------------------------------------------------------

      Waiting for your response :-)


      Thanks in advance.