2 Replies Latest reply on Feb 24, 2010 11:53 AM by eugenbesel

    <rich:columns with filterMethod

    eugenbesel

      hello everyone,

       

      I found the example about extern filtering of DataTable on

      http://livedemo.exadel.com/richfaces-demo/richfaces/filteringFeature.jsf?tab=ex-usage&cid=121451.

       

      I saw, that the filter Method take a Objectvalue.

       

      public boolean filterStates(Object current) {
              Capital currentCapital = (Capital)current;
              if (filterValue.length()==0) {
                  return true;
              }
              if (currentCapital.getState().toLowerCase().startsWith(filterValue.toLowerCase())) {
                  return true;
              }else {
                  return false;
              }
          }

       

       

      and this method is used in jsp. like <rich:column filterMethod="#{filteringBean.filterStates}">

       

      In my case I use dynamic creating of the table with <rich:columns

       

      without filterMethod I made:

      <rich:columns id="col_#{col}" value="#{searchModul.columns}"
                       var="col" index="ind"
                       filterBy="#{data[ind]}" filterEvent="onkeyup" sortBy="#{data[ind]}"
                       sortOrder="#{searchModul.sortOrders[col]}"
                      filterValue="#{searchModul.columnFilterValues[col]}">

       

       

      with Bean:

      public Map<String, Object> getColumnFilterValues() {
              return columnFilterValues;
          }

       

          public void setColumnFilterValues(Map<String, Object> columnFilterValues) {
              this.columnFilterValues = columnFilterValues;
          }

       

      how should it work with filterMethod ????

       

      wich parameter should I provide to my Bean-method?

       

      should it looks like this:

      public boolean filterStates(Map<String, Object> columnFilterValues) {          ????????????

       

      and then?

       

      thank you for your answer.

        • 1. Re: <rich:columns with filterMethod
          eugenbesel

          Hello all,

           

          I implemented my code like im example

           

          <rich:columns id="col_#{col}" value="#{searchModul.columns}"
                           var="col" index="ind"
                           sortBy="#{data[ind]}"
                           sortOrder="#{searchModul.sortOrders[col]}"
                          filterMethod="#{searchModul.filterData}">

          <f:facet name="header">

          <h:inputText value="#{searchModul.columnFilterValues[col]}" id="input">
                                  <a4j:support event="onkeyup" reRender="table , ds2"
                                      ignoreDupResponses="true" requestDelay="700"/>
                              </h:inputText>
                          </f:facet>

          ...

           

          with Bean:

          public Map<String, Object> getColumnFilterValues() {
                  return columnFilterValues;
              }

           

              public void setColumnFilterValues(Map<String, Object> columnFilterValues) {
                  this.columnFilterValues = columnFilterValues;
              }

           

          public boolean filterData(Object current) {

               System.out.println(current);

          }

           

          If I debug into the method filterData, then current-Object is the ArrayList of Strings. I think this is my row.

          On this place I dont know which table column should be filtered. I have also a FilterValue as HashMap<String,Object>. on this place the key of this Map is the column id.

           

          how should I implement filterData-Method?????

           

          I think I dont have enough information for filtering.

           

          ANY IDEA???

          • 2. Re: <rich:columns with filterMethod
            eugenbesel

            I found the problem. thank you