0 Replies Latest reply on Sep 16, 2009 12:22 AM by Vanina Martinez

    rich faces rich:column set properties dynamically

    Vanina Martinez Newbie

      Hi,

      I have a rich:dataTable which I populate dynamically (both data and columns) in the following way:

      <rich:dataTable id="dbcontent" rows = "30" binding="#{myDBTree.mytable}" value="#{myDBTree.data}"
      var ="tuple"
      onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
      onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">

      <f:facet name="header">
      <h:outputText value="Table Contents"/>
      </f:facet>
      </rich:dataTable>

      In myDBTree Bean I have:

      private HtmlDataTable mytable;
      private ArrayList data;

      public void createTable(){

      data = loadData(); //I load this from a database or a file

      for(int i =0; i < columns.size; i++){

      String columnname = columns.get(i);

      HtmlColumn myColumn = (HtmlColumn)application.createComponent(HtmlColumn.COMPONENT_TYPE);

      HtmlOutputText text= (HtmlOutputText )
      FacesContext.getCurrentInstance().
      getApplication().
      createComponent(HtmlOutputText .COMPONENT_TYPE);

      text.setValue(columnname);
      myColumn.setWidth("100px");
      myColumn.getFacets().put("header",text);

      HtmlOutputText colvalue= (HtmlOutputText )
      FacesContext.getCurrentInstance().getApplication().createComponent(HtmlOutputText.COMPONENT_TYPE);

      colvalue.setValueBinding("value", FacesContext.getCurrentInstance() .getApplication().createValueBinding("#{tuple.att}"));

      myColumn.getChildren().add(colvalue);

      mytable.getChildren().add(myColumn);
      }

      There might be a better way of doing this, but this works just fine for me.
      The problem is that now I want to add a filtering to each of those dynamically generated columns and I have no idea how to do it. What I want is to be able to set properties filterBy and filterEvent. I tried the following but didn't work:
      I guess I have to use myColumn.setFilterBy() and myColumn.setFilterEvent("onkeyup"), but I 'm not sure what do I have to pass to setFilterBy.

      If somebody can help me I would really appreciate it. Thanks!

      Vanina