1 Reply Latest reply on Jan 30, 2012 7:51 AM by Jorge Campos

    Dynamic HtmlScrollableDataTable not showing data

    Jorge Campos Newbie

      Hello guys.

       

      I'm creating a coded HtmlScrollableDataTable, the page appears but my table doesn't show.

      Here is the basic structure that I use:

       

      ObjetoComponenteDinamico.java

       

      public class ObjetoComponenteDinamico{
           private String codigo;
           private String descricao;
      
           public String getCodigo(){
                return codigo;
           }
           public void setCodigo(String codigo){
                this.codigo = codigo;
           }
           public String getDescricao(){
                return descricao;
           }
           public void setDescricao(String descricao){
                this.descricao = descricao;
           }
      
      }
      

       

      TesteBean.java

       

      public class TesteBean {
      
      
                private HtmlPanelGrid renderPanel = new HtmlPanelGrid();
        
                private HtmlScrollableDataTable table = new HtmlScrollableDataTable();
        
                private List<ObjetoComponenteDinamico> list = new ArrayList<ObjetoComponenteDinamico>(0);
        
                private DataModel data = new ListDataModel();
        
                private SimpleSelection selection = new SimpleSelection();
        
        
                /**
                 * Construtor padrão da classe
                 */
                public TesteBean(){
                }
      
      
                public HtmlPanelGrid getRenderPanel() {
                          doTable();
                          renderPanel.getChildren().add( table );
                          return renderPanel;
                }
        
                private void doTable() {
                          table.setId("table");
                          table.getChildren().clear();
                          table.setRendererType(HtmlScrollableDataTable.COMPONENT_TYPE);
                          table.setSortMode(HtmlScrollableDataTable.SORT_MULTI);
                          table.setSelectionMode(SelectionMode.multi);
                          table.setRows(10);
                          table.setSelection(selection);
                          table.setRowKeyVar("rkv");
                          table.setWidth("300");
      
      
                          table.setVar("tableVar");
                          table.setValueExpression("value", GeradorUtil.createValueExpression("#{testeBean.data}"));
        
                          HtmlColumn columnCod = new HtmlColumn();
                              columnCod.setRendererType(HtmlColumn.COMPONENT_TYPE);
                          columnCod.setId("columnCod");
      
      
                          HtmlColumn columnDesc = new HtmlColumn();
                              columnDesc.setRendererType(HtmlColumn.COMPONENT_TYPE);
                          columnDesc.setId("columnDesc");
        
                          HtmlOutputText outputCod = new HtmlOutputText();
                              outputCod.setRendererType(HtmlOutputText.COMPONENT_TYPE);
                          HtmlOutputText outputDesc = new HtmlOutputText();
                              outputDesc.setRendererType(HtmlOutputText.COMPONENT_TYPE);
        
                          outputCod.setValueExpression( "value", GeradorUtil.createValueExpression( "#{tableVar.codigo}" ) );
                          outputDesc.setValueExpression( "value", GeradorUtil.createValueExpression( "#{tableVar.descricao}" ) );
        
                          columnCod.getChildren().add(outputCod);
                          columnDesc.getChildren().add(outputDesc);
        
                          table.getChildren().add(columnCod);
                          table.getChildren().add(columnDesc);
                }
        
                public DataModel getData() {
                          list.clear();
                          for (int i = 0; i < 10; i++) {
                                    ObjetoComponenteDinamico obj = new ObjetoComponenteDinamico();
                                    obj.setCodigo("Cod " + i + " ");
                                    obj.setDescricao("Desc " + i + " ");
                                    list.add(obj);
                          }
                          data.setWrappedData(list);
                          return data;
                }
      
      
                public void setRenderPanel(HtmlPanelGrid renderPanel) {
                          this.renderPanel = renderPanel;
                }
      
      
                public HtmlScrollableDataTable getTable() {
                          return table;
                }
      
      
                public void setTable(HtmlScrollableDataTable table) {
                          this.table = table;
                }
      
      
                public List<ObjetoComponenteDinamico> getList() {
                          return list;
                }
      
      
                public void setList(List<ObjetoComponenteDinamico> list) {
                          this.list = list;
                }
      
                public SimpleSelection getSelection() {
                          return selection;
                }
      
                public void setSelection(SimpleSelection selection) {
                          this.selection = selection;
                }
      
                public void setData(DataModel data) {
                          this.data = data;
                }
      
      
      }
      
      

       

      XHTML code

       

      <rich:simpleTogglePanel id="togglePanel" label="Teste" switchType="client">
        
          <h:inputHidden id="cod_atividade" value="1357" />
        
          <a4j:form id="formGeradorRelatorio">
        
                 <h:panelGrid id="renderPanel" binding="#{testeBean.renderPanel}"/>
        
          </a4j:form>
        
      </rich:simpleTogglePanel>
      
      

       

      the result page is in attached image

       

      what am I missing??

       

      any help will be appreciated!

      Tanks in advance