2 Replies Latest reply on Jul 19, 2007 5:46 PM by srilowha

    Dynamically created dataTable doesn't display

    srilowha

      Hello,

      I have the following code in a bean to generate a new tab for a tab panel and to create a data table within it.

      UITab newtab = new HtmlTab();
       newtab.setName("new");
       newtab.setLabel("New");
       newtab.setId("newtab");
      
       HtmlDataTable actionTable = new HtmlDataTable();
       actionTable.setId("table");
       actionTable.setColumns(5);
      
       HtmlColumnGroup headerColGroup = new HtmlColumnGroup();
       headerColGroup.setId("headerColGroup");
       HtmlColumn nameCol = new HtmlColumn();
       nameCol.setId("nameCol");
       HtmlOutputText nameOut = new HtmlOutputText();
       nameOut.setValue("Action");
       nameCol.getChildren().add(nameOut);
       headerColGroup.getChildren().add(nameCol);
      
       HtmlColumn paramCol = new HtmlColumn();
       paramCol.setId("paramCol");
       paramCol.setColspan(4);
       HtmlOutputText paramOut = new HtmlOutputText();
       paramOut.setValue("Parameters");
       paramCol.getChildren().add(paramOut);
       headerColGroup.getChildren().add(paramCol);
      
       actionTable.getFacets().put("header", headerColGroup);
      
       //HtmlColumnGroup colGroup = new HtmlColumnGroup();
       //colGroup.setId("colGroup");
       HtmlColumn namecol = new HtmlColumn();
       namecol.setId("col0");
       HtmlInputText nameinput = new HtmlInputText();
       nameinput.setId("input0");
       namecol.getChildren().add(nameinput);
       //colGroup.getChildren().add(namecol);
       actionTable.getChildren().add(namecol);
       for (int j = 0; j < 4; j++) {
       HtmlColumn col = new HtmlColumn();
       col.setId("col"+(j+1));
       HtmlInputText input = new HtmlInputText();
       input.setId("input"+(j+1));
       input.setStyle("border:0;");
       col.getChildren().add(input);
       //colGroup.getChildren().add(col);
       actionTable.getChildren().add(col);
       }
       //actionTable.getChildren().add(colGroup);
      
       // Add content to tab
       newtab.getChildren().add(actionTable);
      


      From the commented lines you can see that I've tried adding both to a column group and then adding that column group to the table, and also by just directly adding the columns. But in both cases only the header shows up. From the page source of the generated html page, the table looks like:

      <table class="dr-table rich-table " id="frmMain:table" border="0" cellpadding="0" cellspacing="0">
      <colgroup span="5"></colgroup>
      <thead>
      <tr class="dr-table-header rich-table-header ">
      <td class="dr-table-headercell rich-table-headercell ">Action</td>
      <td class="dr-table-headercell rich-table-headercell " colspan="4">Parameters</td>
      </tr>
      </thead>
      <tbody></tbody>
      </table>
      


      The body is completely empty. Before I hadn't given all elements id's, because I thought they might be automatically generated and nothing showed up at all. Now that I've given everything an id, the header appears, but the body is still MIA.

      Any insight on this, or comments on similar problems where components simply did not display would be much appreciated.

      Thanks.