3 Replies Latest reply on Jun 13, 2008 9:00 AM by fillolo

    Creating rich:tabPanel from java code.

    misqu23

      I need to create tabPanel component from within backing bean.

      This is sample code :

       HtmlTab first = new HtmlTab();
       first.setLabel("first");
       first.setName("first");
       HtmlOutputText text1 = new HtmlOutputText();
       text1.setValue("first");
       first.getChildren().add(text1);
       HtmlTab second = new HtmlTab();
       second.setLabel("second");
       second.setName("second");
       HtmlOutputText text2 = new HtmlOutputText();
       text2.setValue("second");
       second.getChildren().add(text2);
       this.tabPanel.getChildren().add(first);
       this.tabPanel.getChildren().add(second);
      


      This code works ok, but I want to add facet to the HtmlTab and I don't know how to do this.
      I was trying use HtmlTab.setName method, I was passing HtmlOutputText object instance as a param of this method but I got NotSerializableException of the object HtmlOutputText.
      I'd like to have tab labels as links and close tab button on the right side of the link that's why I have to add facet.

      Another question is about HtmlTab.setName. When I don't set name of the HtmlTab object I got NullPointerException is this a bug ?

      Thanks in advance for your help

      Martin

        • 1. Re: Creating rich:tabPanel from java code.
          misqu23

          I've found a solution.


          tab.getFacets().put("label", text1);




          • 2. Re: Creating rich:tabPanel from java code.
            fillolo

            Hi ,

            this code doesn't works for me or I can't make it works.

            If I use this code in my backing bean and in the JSF:

             <h:form id="packageOptions">
             <rich:tabPanel switchType="client" binding="#{mybackingbean.tabPanelGenerated}"/>
             </h:form>
            


            The page don't show anything in this section and in the server console I get

            tab panel has no enabled or rendered tabs!


            "tabPanelGenerated" is your "tabPanel" and I've created it in this way
            HtmlTabPanel tabPanelGenerated = new HtmlTabPanel();


            What I'm doing wrong? Do I need to use seteRendered setDisable setActive methods or any other one in the tabs or in the panel? I've tried it but nothing seems to work.

            Could you show me how you include this component in your page?

            Thanks

            • 3. Re: Creating rich:tabPanel from java code.
              fillolo

              I solved it.

              I was worng, you don't need

              HtmlTabPanel tabPanelGenerated = new HtmlTabPanel();


              Thanks.