3 Replies Latest reply on Mar 3, 2009 4:40 AM by Moshe Elisha

    Add a4j:include dynamically from java

    Yaniv David Newbie


      I'm trying to add a4j:include inside a rich tab component dynamically from Java .
      But the include tag isn't being processed. I'm also trying to use UIinclude.
      Note adding an inputText Component does work.
      here is my code:

      public void addTab(ActionEvent event)
       try {
       HtmlTabPanel tabPanel;
       FacesContext context = FacesContext.getCurrentInstance();
       Application application = context.getApplication();
       tabPanel = (HtmlTabPanel)context.getViewRoot().findComponent("form1:tabs");
       HtmlTab tab = (HtmlTab)application.createComponent(HtmlTab.COMPONENT_TYPE);
       HtmlInputText inputText = new HtmlInputText();
       UIInclude includeTag = (UIInclude)application.createComponent(UIInclude.COMPONENT_TYPE);
       Include A4Jinclude = new Include();
       A4Jinclude.setId("inc" + this.count++);
       includeTag.setId("inc" + this.count++);
       tab.setLabel("YANIV TEST");
       tab.setId("newtab" + this.count);
       tabPanel.setSelectedTab("newtab" + this.count);
       } catch (FacesException ex) {
       Audit.error("", ex);

      How can I make this work?

      Thank you very much in advance,

        • 1. Re: Add a4j:include dynamically from java
          Moshe Elisha Newbie


          I am having the same problem. Did you find a solution?

          • 2. Re: Add a4j:include dynamically from java
            Yaniv David Newbie

            No sorry mate.
            I got no more hair on my head from this.

            I tried to do something else using YUI tabs
            adding a tab from javascript and setting it's data src to a url
            but there is a different problem with doing that; The viewstate id is causing problems since it's generating another view id and reseting it for all others. :(

            If you have something please let me know.

            • 3. Re: Add a4j:include dynamically from java
              Moshe Elisha Newbie

              In my case I needed dynamic tabs but all the tabs had the same content so I did it using c:forEach tag:


              <r:tabPanel id="systemHealthTabPanel" switchType="ajax" selectedTab="#{healthMonitor.selectedSubSystemID}" >
               <c:forEach items="#{healthMonitor.subSystemTabs}" var="subSystemTab">
               <r:tab name="#{subSystemTab.id}" label="#{subSystemTab.label}" action="#{healthMonitor.buildHealthData}">
               <f:subview id="subSystemSubview#{subSystemTab.id}" rendered="#{healthMonitor.selectedSubSystemID == subSystemTab.id}">
               <a4j:include id="subSystemTabInclude" viewId="/pages/systemHealth/systemHealthPerSubSystem.xhtml"/>

              The subSystemTabs return an array of SubSystemTab which has two fields id and label.