14 Replies Latest reply on Mar 30, 2013 7:07 AM by AINDRILA ACHARYA

    Dynamic tabs with Richfaces 4

    Jamie Steward Newbie

      We are running Richfaces 4.0 CR1 and have the following problem.

       

      The only way we could get dynamic tabs to work in a <rich:tabPanel> is by using a <c:forEach> tag:

       

      <rich:tabPanel switchType="client" activeItem="#{notesBean.activeTab}">

       

           <c:forEach items="#{notesBean.noteTabs}" var="noteTab">

       

                 <rich:tab name="#{noteTab.id}" action="#{notesBean.setActiveTab(noteTab.id)}">
                       <f:facet name="header">
                        .. tab header here ...
                       </f:facet>

                       <h:panelGrid>
                        .. tab content here...

                       </h:panelGrid>

                 </rich:tab>

       

           </c:forEach>

       

      </rich:tabPanel>

       

       

      The NotesBean.java class looks like this:

       

      @ManagedBean

      @SessionScoped

      public class NotesBean implements Serializable {

          private static final long serialVersionUID = -4058494777249034839L;

       


          private String activeTab = "";

          private List<NoteTab> noteTabs = new ArrayList<NoteTab>();

       

           ... accessors here ....   

       

      }

       

      The NoteTab.java class has two string fields: name & id.

       

      The problem is that we get a null pointer exception when RichFaces tries to render the <rich:tabPanel> it tries to set the active tab before the <rich:tab> has been rendered!

       

      I tried using a <ui:repeat> or <a4j:repeat> to create dynamic tabs, but neither works...

       

      Please help.

      ~ Jamie

        • 1. Dynamic tabs with Richfaces 4
          Ilya Shaikovsky Master

          I believe i reported it already some time ago.. just provide activeItem (set to the first tab name) and it should start works fine with foreach.

          • 2. Re: Dynamic tabs with Richfaces 4
            barmic Newbie

            Hello,

             

            I have the same problem and I use an activeItem this is my code :

            <rich:tabPanel xmlns="http://www.w3.org/1999/xhtml"

                           xmlns:h="http://java.sun.com/jsf/html"

                           xmlns:f="http://java.sun.com/jsf/core"

                           xmlns:ui="http://java.sun.com/jsf/facelets"

                           xmlns:rich="http://richfaces.org/rich"

                           xmlns:a4j="http://richfaces.org/a4j"

                           xmlns:c="http://java.sun.com/jsp/jstl/core"

                           switchType="client" activeItem="#{findLot.lot.operations[0]['code']}" >

                <c:forEach items="#{findLot.lot.operations}" var="ope" >

                    <rich:tab header="#{ope['code']}" name="#{ope['code']}" >

                        <p>Non implémenté</p>

                    </rich:tab>

                </c:forEach>

            </rich:tabPanel>

             

            findLot.lot.operations is a List<Map<String, String>> and it's correctly initialized (I can display it in dataGrid for exemple), but no tab are displayed, I have only the main frame of <richtabPanel>. The value of "code" is uniqu in the list.

             

            I have forgotten any things ?

             

            Edit : I update from M6 to CR1 and I have the same problem. My code is :

            <rich:tabPanel xmlns="http://www.w3.org/1999/xhtml"

                           xmlns:h="http://java.sun.com/jsf/html"

                           xmlns:f="http://java.sun.com/jsf/core"

                           xmlns:ui="http://java.sun.com/jsf/facelets"

                           xmlns:rich="http://richfaces.org/rich"

                           xmlns:a4j="http://richfaces.org/a4j"

                           xmlns:c="http://java.sun.com/jsp/jstl/core"

                           switchType="client" activeItem="#{findLot.lot.operations[0]['code']}" >

                <c:forEach items="#{findLot.lot.operations}" var="ope" >

                    <rich:tab header="#{ope['code']}" name="#{ope['code']}" >

                        <p>Non implémenté</p>

                    </rich:tab>

                </c:forEach>

            </rich:tabPanel>

             

            And when I execute my app I have an NullPointer exception :

            24 mars 2011 16:57:21 org.richfaces.context.ExtendedPartialViewContextImpl$RenderVisitCallback logException

            GRAVE: null

            java.lang.NullPointerException

                      at org.richfaces.component.AbstractTabPanel.getActiveItem(AbstractTabPanel.java:64)

                      at org.richfaces.component.AbstractTogglePanel.encodeBegin(AbstractTogglePanel.java:168)

                      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1611)

                      at org.richfaces.renderkit.RendererBase.renderChildren(RendererBase.java:278)

                      at org.richfaces.renderkit.html.CollapsiblePanelRenderer.encodeContent(CollapsiblePanelRenderer.java:215)

                      at org.richfaces.renderkit.html.CollapsiblePanelRenderer.encodeContentChild(CollapsiblePanelRenderer.java:161)

                      at org.richfaces.renderkit.html.CollapsiblePanelRenderer.doEncodeChildren(CollapsiblePanelRenderer.java:155)

                      at org.richfaces.renderkit.RendererBase.encodeChildren(RendererBase.java:157)

            • 3. Re: Dynamic tabs with Richfaces 4
              Ilya Shaikovsky Master

              so that's #{findLot.lot.operations[0]['code']} probably getting evaluated to null.

               

              You could see that code working right now there

              http://richfaces-showcase.appspot.com/richfaces/component-sample.jsf?demo=ajax&skin=blueSky

               

              Left panelMenu and samples chooser tabPanel both using c:forEach:

              component-sample.xhtml

              navigation.xhtml

               

              Maybe you have outdated version. try to checkout the code from that branch http://anonsvn.jboss.org/repos/richfaces/branches/4.0.X/ and build it locally.

              • 4. Re: Dynamic tabs with Richfaces 4
                Sebastian Götz Newbie

                Dear Ilya,

                 

                I think I have made no error when trying to solve my problem which is the same as Jamie's above. In my page I have a simple tabPanel containing up to three tabs. By the way I am using richfaces 4.0.0.Final.

                 

                <rich:tabPanel id="projectDataTabPanel" switchType="client" activeItem="#{costumerProjectBean.activeTab}">

                     <rich:tab name="projectDataTab" header="#{tr.lbl_projectData}">

                          <h:panelGrid columns="3" columnClasses="none, none, noWidth">

                          ...

                     </rich:tab>

                     <rich:tab name="pktTab" header="#{tr.lbl_pktData}" rendered="#{customerProjectBean.project.pktConfiguration.usePKT}">

                     ...

                     </rich:tab>

                </rich:tabPanel>

                 

                 

                In my bean class I have simple getters and setters for this property (activeTab) and the initial value set to the name of the first tab.

                 

                private String activeTab = "projectDataTab";

                 

                public void setActiveTab(final String activeTab)

                    {

                        this.activeTab = activeTab;

                    }

                 

                    public String getActiveTab()

                    {

                        return activeTab;

                    }

                 

                The most strange thing is that I get the NullPointerException before my breakpoint on the get-method is reached. How can that be? The exact exception stack is:

                 

                29.08.2011 15:12:34 com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException

                SCHWERWIEGEND: Error Rendering View[/customerProjectEdit.xhtml]

                java.lang.NullPointerException

                    at org.richfaces.component.AbstractTabPanel.getActiveItem(AbstractTabPanel.java:64)

                    at org.richfaces.component.AbstractTogglePanel.encodeBegin(AbstractTogglePanel.java:168)

                    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)

                    at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)

                    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:853)

                    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1652)

                    at org.richfaces.renderkit.RendererBase.renderChildren(RendererBase.java:278)

                    at org.richfaces.renderkit.html.PanelRenderer.encodeEnd(PanelRenderer.java:181)

                    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:883)

                    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1659)

                    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655)

                    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655)

                    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:399)

                    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)

                    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)

                    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)

                    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

                    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)

                    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

                    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)

                    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)

                    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)

                    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)

                    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)

                    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)

                    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)

                    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)

                    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)

                    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)

                    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)

                    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)

                    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)

                    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)

                    at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)

                    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)

                    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)

                    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)

                    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)

                    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)

                    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)

                    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)

                    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)

                    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)

                    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

                    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

                    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

                    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

                    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

                    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)

                    at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:886)

                    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:721)

                    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:2256)

                    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                    at java.lang.Thread.run(Thread.java:619)

                 

                Am I damn blind to see it or what is it?

                 

                Best regards,

                 

                Sebastian

                • 5. Re: Dynamic tabs with Richfaces 4
                  Sebastian Götz Newbie

                  Is there no one who has/had the same problem? I cannot believe that thi sis true...

                  • 6. Re: Dynamic tabs with Richfaces 4
                    larsd Newbie

                    I've got the same issue. Tried to use id, name, both,... nothing worked... :-(

                     

                    getActiveTab() is called before the NullPointer Exception...

                     

                     

                    <a4j:outputPanel

                            id="tabPanel"

                            >

                     

                            <rich:tabPanel

                                id="topicOverviewTabs"

                                switchType="ajax"

                                activeItem="#{myBean.activeTab}">

                     

                                <rich:tab

                                    id="reasonsTab"

                                    name="reasonsTab"

                                    header="#{commonTrans.corTopicReasons}"

                                    rendered="..."

                                    onenter="#{myBean.setActiveTab('reasonsTab')}">

                                    ...

                                </rich:tab>

                     

                                <rich:tab

                                    id="mappingsTab"

                                    name="mappingsTab"

                                    header="#{commonTrans.corTopicMappings}"

                                    rendered="..."

                                    onenter="#{myBean.setActiveTab('mappingsTab')}">

                                    ...

                                </rich:tab>

                     

                            </rich:tabPanel>

                        </a4j:outputPanel>

                     

                     

                     

                    @Named

                    @ViewAccessScoped

                    public class MyBean implements Serializable {

                         ...

                         private String activeTab = "reasonsTab";

                         ...

                     

                    ...

                     

                    public String getActiveTab() {

                            return activeTab;

                        }

                     

                    public void setActiveTab(String activeTab) {

                            this.activeTab = activeTab;

                        }

                     

                     

                     

                     

                    type Exception report

                    message

                    description The server encountered an internal error () that prevented it from fulfilling this request.

                    exception

                    javax.servlet.ServletException javax.faces.webapp.FacesServlet.service(FacesServlet.java:325) com.lpsolutions.gui.common.listener.SessionInvalidationFilter.doFilter(SessionInvalidationFilter.java:44) com.lpsolutions.gui.common.listener.RequestContextSetupFilter.doFilter(RequestContextSetupFilter.java:64) org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:351) 

                    root cause

                    java.lang.NullPointerException org.richfaces.component.AbstractTabPanel.getActiveItem(AbstractTabPanel.java:64) org.richfaces.component.AbstractTogglePanel.encodeBegin(AbstractTogglePanel.java:168) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1611) org.richfaces.renderkit.RendererBase.renderChildren(RendererBase.java:278) org.richfaces.renderkit.html.AjaxOutputPanelRenderer.encodeChildren(AjaxOutputPanelRenderer.java:58) javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616) com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380) com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126) javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273) javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273) javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273) javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273) org.apache.myfaces.tomahawk.application.ResourceViewHandlerWrapper.renderView(ResourceViewHandlerWrapper.java:93) com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127) com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleWrapper.render(CodiLifecycleWrapper.java:122) javax.faces.webapp.FacesServlet.service(FacesServlet.java:313) com.lpsolutions.gui.common.listener.SessionInvalidationFilter.doFilter(SessionInvalidationFilter.java:44) com.lpsolutions.gui.common.listener.RequestContextSetupFilter.doFilter(RequestContextSetupFilter.java:64) org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349) 

                    note The full stack trace of the root cause is available in the Apache Tomcat/7.0.8 logs.

                    • 7. Re: Dynamic tabs with Richfaces 4
                      Karsten Wutzke Expert

                      I also have this bug. NPE when activating tabs. Horrible. And no workaround.

                       

                      Karsten

                      • 8. Re: Dynamic tabs with Richfaces 4
                        larsd Newbie

                        I found the problem at my project. If the rendered attribute returns false, the tabPanel of course can't find the tab which should be shown.

                         

                        But I suggest to catch this NullPointer Exception and implement a fall back to the next possible tab. Also I'm unable to save the selected tab in the bean, but i will open another discussion for this issue.

                         

                        kind regards.

                        • 9. Re: Dynamic tabs with Richfaces 4
                          Gurinder Randhawa Newbie

                          We are having the same issue and use activeItem, just upgraded libraries to 4.1.0 M3 problem still occurs our model contains at least 1 tab, however we receive an NPE

                          when rendering the panel.

                           

                          ERROR:

                          java.lang.NullPointerException

                                  at org.richfaces.component.AbstractTabPanel.getActiveItem(AbstractTabPanel.java:59)

                           

                          XHTML CODE:

                          <rich:tabPanel id="logNotesTabPanel" switchType="client" rendered="#{not empty logNotesBean.logNoteOwners}" activeItem="#{logNotesBean.activeTab}">

                                              <c:forEach items="#{logNotesBean.logNoteOwners}" var="owner" varStatus="status">

                                                  <rich:tab name="#{owner.ownerRefId}" id="tabLogNotes#{status.index}" switchType="client">

                           

                          Our bean is session scoped and data is set containing at least one data item to render tab, looks like getActiveItem is getting called before model is being set somehow??

                          • 10. Re: Dynamic tabs with Richfaces 4
                            Sebastian Götz Newbie

                            Finally I got back to work on JSF with RichFaces.

                             

                            After some investigation I could solve the problem for me. My problem was, that with switchType="client" the itemChangeListener does not get notified. This is not a bug but explained in the docs. So I changed to switchType="ajax". But still it woul dnot work as expected. The last piece of the puzzle was, that you need an itemChangeListener to change the value of your activeItem member in your backing bean. Here is my final example:

                             

                            <rich:tabPanel id="projectDataTabPanel" switchType="ajax" activeItem="#{customerProjectBean.activeItem}" itemChangeListener="#{customerProjectBean.processItemChange}">
                            

                             

                            The backing bean's methods look like this:

                             

                                public void setActiveItem(final String activeTab)
                                {
                                    this.activeItem = activeTab;
                                }
                            
                                public String getActiveItem()
                                {
                                    if (activeItem == null)
                                    {
                                        activeItem = "projectDataTab";
                                    }
                                    return activeItem;
                                }
                            
                                
                                @Override
                                public void processItemChange(final ItemChangeEvent p_event) throws AbortProcessingException
                                {
                                    log.debug("ItemChangeEvent: " + p_event.getOldItemName() + " => " + p_event.getNewItemName());
                                    setActiveItem(p_event.getNewItemName());
                            
                                    FacesContext.getCurrentInstance().renderResponse();
                                }
                            

                             

                            The getActiveTab() returns the id of the default <rich:tab/> component if it is in initial state. With this configuration it works as expected, showing the selected tab after a request.

                            I hope someone can use this explanation.

                             

                            Regards,

                             

                            Sebastian

                            • 11. Re: Dynamic tabs with Richfaces 4
                              ameo Novice

                              Hello,

                               

                              i still have this problem for the dynamically creation of tabPanels.

                               

                              [org.richfaces.log.Context] (http--127.0.0.1-8080-1) null: java.lang.NullPointerException

                                at org.richfaces.component.AbstractTabPanel.getActiveItem(AbstractTabPanel.java:67) [richfaces-components-ui-4.3.0.2012080

                               

                              RF 4.3.0.20120802-M1

                              JSF 2.0

                              JBoss AS 7

                               

                              I alredy read all the postings, but I think the problem is not solved.

                              -RF-10961

                              -RF-10989

                              -RF-10951

                              Also https://community.jboss.org/message/625547

                               

                              Here are some code snippets:

                               

                              <rich:tabPanel id="mypanel" switchType="ajax" activeItem="#{bb.activeItem}" rendered="#{not empty bb.panels}">

                               

                                        <ui:repeat var="panel" value="#{bb.panels}">

                                     

                                        <rich:tab header="#{panel.name}  name="#{panel.name}" rendered="#{not empty bb.panels}" >

                               

                              I already tried with <c:forEach> and <a4j:repeat>

                              The same code works fine with <rich:collapsiblePanel>

                              The ManagedBean is SessionScoped.

                              I tried all switchTypes..

                              The workaround with adding a getActiveItem method or how described here adding a processItemChange method did not solve the NPE.

                               

                              It would be nice, if someone have a workaround for this,

                               

                              Greetings,

                              ameo

                              • 12. Re: Dynamic tabs with Richfaces 4
                                ameo Novice

                                Hello...

                                 

                                Does no one have a solution to the problem described above?

                                 

                                Greetings..

                                ameo

                                • 13. Re: Dynamic tabs with Richfaces 4
                                  Sergey Morenets Novice

                                  Hi, ameo!

                                   

                                  I guess the best way out is to accept the situation that RF is just not supporting this feature ....

                                  • 14. Re: Dynamic tabs with Richfaces 4
                                    AINDRILA ACHARYA Newbie

                                    I am using richface 4.3.1 and This code snippet working fine with me

                                     

                                    <ui:define name="content">

                                            <h:form id="homeForm">

                                            <h:panelGrid id="PanelGrid">

                                            <ui:insert name="body">

                                            <rich:tabPanel switchType="ajax" id="mainTabPanel" headerLocation="center">

                                            <rich:tab header="#{menuCreator.bodyHead}" id="mainTabPanel1">

                                                <ui:include src="" />                       

                                            </rich:tab>

                                    //DYNAMICALLY ADDED TAB PORTION CODE GOES HERE

                                            <a4j:repeat value="#{beanClass.test}" var="skinName" >

                                            <rich:tab header="#{skinName}" name="#{skinName}">

                                            <ui:define name="body">

                                            <a4j:region id="abc">

                                                <a4j:commandLink

                                                        action="#{beanClass.save}"

                                                        id="save"

                                                        render="homeForm:categoryPanel"

                                                        title="Save" execute="homeForm:abc" />

                                                       

                                                    <rich:panel header="INFORMATION" id="categoryPanel">

                                                        <h:outputLabel value="branchcode"/>

                                                        <h:inputText id="branchcode" value="#{beanClass.branchcode}"/>

                                                        <h:outputLabel value="branchname"/>

                                                        <h:inputText id="branchname" value="#{beanClass.branchname}" />

                                                    </rich:panel>

                                                   

                                                    </a4j:region>

                                                    </ui:define>               

                                            </rich:tab>

                                        </a4j:repeat>

                                    </rich:tabPanel>

                                    <a4j:commandLink values="#{testClass.dynamicTabAdd}" render="mainTabPanel"

                                                </ui:insert>

                                            </h:panelGrid>   

                                           

                                     

                                        </h:form>

                                    </ui:define>

                                     

                                    BEAN CLASS:

                                    public void testClass implements Serializable{

                                     

                                     

                                    private String changeTabValue="";

                                        List<String> test = new ArrayList<String>();

                                     

                                    public String getChangeTabValue() {

                                            return changeTabValue;

                                        }

                                     

                                        public void setChangeTabValue(String changeTabValue) {

                                            this.changeTabValue = changeTabValue;

                                        }

                                     

                                        public List<String> getTest() {

                                            return test;

                                        }

                                     

                                        public void setTest(List<String> test) {

                                            this.test = test;

                                        }

                                     

                                    public void dynamicTabAdd(){          

                                            this.setChangeTabValue("TAB"+uploadId);        

                                            test.add(changeTabValue);          

                                        }

                                     

                                    }