4 Replies Latest reply on Dec 18, 2008 8:20 PM by wind1heart

    Re-ordering tabs

    wind1heart

      I'm using the following line in a back bean to add a tab dynamically.

      tabPanel.getChildren().add(newTab);

      How can I re-order the tabs I created in the back bean? i.e. "Tab A" > "Tab B" > "Tab C" reorder as "Tab A" > "Tab C" > "Tab B"


      Thanks in advance.

        • 1. Re: Re-ordering tabs
          ilya_shaikovsky

          the questions seems the same as how to swap two objects in a collection ;)

          • 2. Re: Re-ordering tabs
            wind1heart

            I found the newly created tab places at the end of the list. However, it will always appear as the first tab. Indeed, I want it be the last one. Any solution?

            • 3. Re: Re-ordering tabs
              ilya_shaikovsky

              show you code snippets for the case please.

              • 4. Re: Re-ordering tabs
                wind1heart

                Originally, there are tabs "OuterTabA" and "OuterTabB". When user click on a checkbox, method addTabs will be entered.

                public void addTabs(ValueChangeEvent event) {
                FacesContext context = FacesContext.getCurrentInstance();
                Application application = context.getApplication();
                HtmlTab newTab = (HtmlTab) application.createComponent(HtmlTab.COMPONENT_TYPE);

                newTab.setId("OuterTabC");
                newTab.setLabel("OuterTabC");
                tabPanel.getChildren().add(newTab);
                }

                The result is, I can see the tabs in this order "OuterTabC", "OuterTabA", "OuterTabB". However, I want the new tab place at the end.