8 Replies Latest reply on Nov 13, 2007 1:39 PM by bradmesserle

    Hardcoding (dynamic) tabs

    bradmesserle

      I am trying to generate tabs via java code.

      private HtmlTabPanel myTab = new HtmlTabPanel();
      private HtmlTab tab1 = new HtmlTab();
      private HtmlTab tab2 = new HtmlTab();


      All works great but the question is how do i get the html code in the tab?
      I dont mind having the html code in the backing bean, i just dont know how to get it to display in the tab.


      Any ideas?

      Thanks!

        • 1. Re: Hardcoding (dynamic) tabs

          I'not sure if I really understand your question. Perhaps this helps:

          What about:

           HtmlTab tab = new HtmlTab();
           HtmlPanel panel = new HtmlPanel();
           panel.setParent(tab);
           //and so on
          


          And do you know the binding attribute and the use of it?

          • 2. Re: Hardcoding (dynamic) tabs
            bradmesserle

            That part works fine..

            I am having trouble putting content in the tab.. For example a simple table with a few columns and text..

            Thanks!

            • 3. Re: Hardcoding (dynamic) tabs

              Hmm...I'm confused. Was that post from you a "Thanks for help" or a "Thanks but my problem is not solved"???

              Let's assume the second case :-) Perhaps I'm totally wrong put I think the key to your problem is to set the parent. What I mean:

              1.) Create your table with this Html*-Classes.
              2.) Create a panel.
              3.) Set the panel as parent of the table.
              4.) Create a tab.
              5.) Set the tab as parent of the panel.

              Or does that not work?

              • 4. Re: Hardcoding (dynamic) tabs
                bradmesserle

                Sorry this might be a dumb question..

                But the part i am having trouble with is item 1. :)

                I dont know how/having trouble creating Html code via java code.

                I think once I know the set of classes i am good..

                Here is some code i have tried and is not working I get dup id as an error..

                HtmlPanel aPanel = new HtmlPanel();
                HtmlPanelGrid grid = new HtmlPanelGrid();
                grid.setId("test_1");

                HtmlOutputText html1Text = new HtmlOutputText();
                html1Text.setValue("Testing 1 2 3");
                html1Text.setId("Test_2");

                HtmlOutputText html2Text = new HtmlOutputText();
                html2Text.setValue("Testing 3 4 5 6");
                html2Text.setId("Test_3");

                grid.getChildren().add(html1Text);
                grid.getChildren().add(html2Text);

                aPanel.getChildren().add(grid);


                -Brad

                • 5. Re: Hardcoding (dynamic) tabs

                  I'm not an expert in writing html pages this way but what is wrong with this code (corresponding to my suggestion above):

                   //1.
                   HtmlDataTable table = new HtmlDataTable();
                   //2.
                   HtmlPanel panel = new HtmlPanel();
                   //3.
                   table.setParent(panel);
                   //4.
                   HtmlTab tab = new HtmlTab();
                   //5.
                   panel.setParent(tab);
                  


                  Please notice: Set Parent, not child.

                  • 6. Re: Hardcoding (dynamic) tabs
                    bradmesserle

                    ok i will give that a try.

                    Thank you for all your help.

                    • 7. Re: Hardcoding (dynamic) tabs

                      Ah, don't mention it. I did not say that works. I only wanna say, I understand the documentation in this way ;-)

                      Nice to have: The sections with headings "Creating the Component Dynamically Using Java" should not be so...short. Or what do you think?

                      • 8. Re: Hardcoding (dynamic) tabs
                        bradmesserle

                        Exactly.. I think they should come up with some really good sample code.

                        Setting the parent did not work for me. The page did not display the controls.

                        Thanks!