0 Replies Latest reply on Mar 16, 2012 10:57 AM by trigun

    Dynamic extendedDataTable

    trigun

      Hi,

       

      i try to create a extendedDataTable from a Bean, Working on IBM WAS 7 and Richfaces 3.3.3 Final:

       

      my .xhtml looks like this:

       

       

      <h:form id="tcForm">
           <h:panelGroup id="panelTestTbl" binding="#{testCaseTable.dataTableGroup }" />
             <rich:contextMenu id="ctxMenu" binding="#{testCaseTable.ctxMenu }" >
             </rich:contextMenu>
       </h:form>
      

       

      my Bean:

       

       

      public class TestCaseTable {
                private UIExtendedDataTable custumExtDataTbl;
                private HtmlPanelGroup dataTableGroup; // Placeholder.
      
      
           // Getters -----------------------------------------------------------------------------------
      
      
          public HtmlPanelGroup getDataTableGroup() {
              // This will be called once in the first RESTORE VIEW phase.
              if (dataTableGroup == null) {
                  populateDataTable(); // Populate datatable.
              }
              return dataTableGroup;
          }
      
      
          // Setters -----------------------------------------------------------------------------------
      
      
          public void setDataTableGroup(HtmlPanelGroup dataTableGroup) {
              this.dataTableGroup = dataTableGroup;
          }
      
                public void populateDataTable() {
                         
      ExpressionFactory elFactory = FacesContext.getCurrentInstance().getApplication().getExpressionFactory();
                          ELContext elContext = FacesContext.getCurrentInstance().getELContext();
                          Application app = FacesContext.getCurrentInstance().getApplication();
        
                          /* Create the HtmlExtendedDataTable */
                          custumExtDataTbl = (UIExtendedDataTable) app.createComponent(UIExtendedDataTable.COMPONENT_TYPE);
                          custumExtDataTbl.setValueExpression("selection",
                                              elFactory.createValueExpression(elContext, "#{testCaseTable.selection}", Selection.class));
                          custumExtDataTbl.setValueExpression("value",
                                              elFactory.createValueExpression(elContext, "#{testCaseTable.parentTestCases}", ArrayList.class));
                          custumExtDataTbl.setVar("testCase");
                          custumExtDataTbl.setRows(25);
                          custumExtDataTbl.setId("customTestTbl");
        
                          /* Create the columns */
                          UIColumn namCol = (UIColumn) app.createComponent(UIColumn.COMPONENT_TYPE);
                          custumExtDataTbl.getChildren().add(namCol);
        
                              HtmlOutputText idHeader = new HtmlOutputText();
                             idHeader.setValue("NAME");
                             idHeader.setId("nameHead");
                             namCol.setHeader(idHeader);
                             namCol.setId("colName");
              
                            HtmlOutputText idOutput = new HtmlOutputText();
                            idOutput.setValueExpression("value",
                                  elFactory.createValueExpression(elContext, "#{testCase.name}", String.class));
                             idOutput.setId("colNameTxt");
                             namCol.getChildren().add(idOutput);
        
                          // Finally add the datatable to <h:panelGroup binding="#{myBean.dataTableGroup}">.
                             dataTableGroup = new HtmlPanelGroup();
                             dataTableGroup.getChildren().add(custumExtDataTbl);
      
      
                }
      
      

      I get no errors, but my Table did noch show some Data. Even the header is not displayed. Only the borders of the Table.

       

      Any ideas ? Thank you