2 Replies Latest reply on Aug 20, 2009 3:26 AM by Ilya Shaikovsky

    rich:tabPanel dynamic tabs

    marian ristouche Newbie

      Hi there,

      I want to create dynamic tabs into a <rich:tabPanel>, iterating on a List of Objects.
      I tried with c:forEach JSTL's componenent, but it doesn't work as it says

      "#" is not allowed in template text
      


      So, I tried to do it in the corresponding Java bean, and it partially worked, because my tabs are created but they are empty.
      Let me give you the code:
      <rich:tabPanel switchType="client" binding="#{dataBase.mytabPanel}">
      </rich:tabPanel>
      

      and
      public HtmlTabPanel getMytabPanel() {
       List<List<UISelectItem>> selectItemTab=SelectItemConverter.listMapToUISelectItems(dataBase.getListVarContent(chosenVariablesNames));
       FacesContext context = FacesContext.getCurrentInstance();
       Application application = context.getApplication();
       mytabPanel = (HtmlTabPanel)application.createComponent(HtmlTabPanel.COMPONENT_TYPE);
      
       for (int i=0; i<selectItemTab.size();i++){
       HtmlTab tab = (HtmlTab)application.createComponent(HtmlTab.COMPONENT_TYPE);
       tab.setLabel("Variable: " + String.valueOf(i));
       tab.getChildren().addAll(selectItemTab.get(i));
       mytabPanel.getChildren().add(tab);
       }
       return mytabPanel;
       }
      

      I want to add SelectItems in every tab.
      I make the precision that none of my lists are empty.

      If I switch the UISelectItem to UIOutPut and set the UIOutPut value to "test", then "test" is displayed in every tab, so it works with UIOutPut.

      Is HtmlTab working with UISelectItem?

      Thank you!

        • 1. Re: rich:tabPanel dynamic tabs
          marian ristouche Newbie

          I found my mistake, I forgot to put the SelectItems in a SelectMany component, so here is the code if it can help someone:

          public HtmlTabPanel getMytabPanel() {
           List<List<UISelectItem>> selectItemTab=SelectItemConverter.listMapToUISelectItems(dataBase.getListVarContent(chosenVariablesNames));
           FacesContext context = FacesContext.getCurrentInstance();
           Application application = context.getApplication();
           mytabPanel = (HtmlTabPanel)application.createComponent(HtmlTabPanel.COMPONENT_TYPE);
          
           for (int i=0; i<selectItemTab.size();i++){
           HtmlTab tab = (HtmlTab)application.createComponent(HtmlTab.COMPONENT_TYPE);
           tab.setLabel("Variable: " + String.valueOf(i));
           UISelectMany selectMany=new UISelectMany();
           selectMany.getChildren().addAll(selectItemTab.get(i));
           tab.getChildren().add(selectMany);
           mytabPanel.getChildren().add(tab);
           }
           return mytabPanel;
           }