5 Replies Latest reply on Nov 25, 2008 9:26 AM by ilya_shaikovsky

    tabs with includes

    quartilan

      Hey

      I managed to add new tabs and remove them but with a fixed number of predefined tabs. The problem I'm having is that when I create a new tab I need to rerender the TabPanel, but I only want to rerender the newly created tab.

      I need this because it is possible to have the same page in different tabs.

      Is there any way to rerender the tabpanel without rerendering its allready filled in children?

      This is what my page with the tabs looks like.

      <rich:tabPanel id="tabs" switchType="client" >
       <rich:tab label="Overview" binding="#{navigationBean.tab1}">
       <a4j:include id="include1" viewId="#{navigationBean.path1}" />
       </rich:tab>
       <rich:tab label=" " style="display:none" name="tab2" ontabenter="updateActiveTab('tab2')" binding="#{navigationBean.tab2}" >
       <h:panelGroup style="float:right; margin-top:-5px">
       <h:form>
       <a4j:commandLink reRender="tabs" action="#{navigationBean.removeTab}">
       <h:graphicImage value="/images/closeicon.gif" />
       <a4j:actionparam name="removedTab" value="tab2" assignTo="#{navigationBean.removedTab}" />
       </a4j:commandLink>
       </h:form>
       </h:panelGroup>
       <a4j:include id="tab2" viewId="#{navigationBean.path2}" />
       </rich:tab>
       <rich:tab label=" " style="display:none" name="tab3" ontabenter="updateActiveTab('tab3')" binding="#{navigationBean.tab3}">
       <h:panelGroup style="float:right; margin-top:-5px">
       <h:form>
       <a4j:commandLink reRender="tabs" action="#{navigationBean.removeTab}">
       <h:graphicImage value="/images/closeicon.gif" />
       <a4j:actionparam name="removedTab" value="tab3" assignTo="#{navigationBean.removedTab}" />
       </a4j:commandLink>
       </h:form>
       </h:panelGroup>
       <a4j:include id="tab3" viewId="#{navigationBean.path3}" />
       </rich:tab>
      </rich:tabPanel>
      


        • 1. Re: tabs with includes
          quartilan

          Or is there a way to save the state of the include page to reinclude in the tab after the rerender of the tabs?

          • 2. Re: tabs with includes
            ilya_shaikovsky

            if you reRender tabPanel - only selected tab reRendered using ajax switchType.

            • 3. Re: tabs with includes
              quartilan

              Problem is:

              Tab1: search with result in it.
              I add a new tab with the same page in it. After the adding of this new tab I have to rerender the tabpanel to show the newly added tab. The problem is then that tab1 gets rerendered too. Thus I lose the result from the search in the first tab.

              The switch type of the panel is "client" and this works ok. I I switch between the panel there is no problem. Only if I create a new tab.

              This is the way I add a new tab:

              <a4j:commandLink reRender="tabs" value="#{msg.attestationMenu}" style="font: menu;" action="#{navigationBean.addNewTab}">
               <a4j:actionparam name="requestedPath" value="/pages/attestation/attestationOverview.jsp" assignTo="#{navigationBean.requestedPath}" />
               <a4j:actionparam name="tabLabel" value="#{msg.attestationMenu}" assignTo="#{navigationBean.tabLabel}" />
              </a4j:commandLink>


              NavigationBean:
              public void addNewTab() {
              
               if (this.tab2.getStyle().equalsIgnoreCase("display:none")) {
               tab.setRendered(true);
               tab.setLabel(tabLabel);
               tab.setStyle("display:block");
               if (!renderedTabNames.contains(tab.getName())) {
               renderedTabNames.add(tab.getName().toString());
               }
               this.path2 = this.requestedPath;
               ((HtmlTabPanel)this.tab.getParent()).setSelectedTab(this.tab.getName());
              }
              


              • 4. Re: tabs with includes
                quartilan

                EDIT :first tab2 must be tab

                • 5. Re: tabs with includes
                  ilya_shaikovsky