3 Replies Latest reply on Oct 3, 2008 5:39 AM by Andrei Markavtsov

    DATATABLE : filterBy + dynamic columns don't work

    Nicolas Feybesse Newbie

      Hello.

      FilterBy feature don't work in datatable with dynamic columns.
      Filtering is applied on the last column for each inputtext.

      Here is a simple test case :

      
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:a="http://richfaces.org/a4j"
       xmlns:c="http://java.sun.com/jstl/core"
       xmlns:rich="http://richfaces.org/rich">
      
      <body>
      <f:view>
       <h:form>
       <rich:dataTable sortMode="single" value="#{testBean.rows}" var="row">
       <rich:columns value="#{testBean.columns}" var="column" index="ind" filterBy="#{row[ind]}">
       <f:facet name="header">
       <h:outputText value="#{column}" />
       </f:facet>
       <h:outputText value="#{row[ind]}" />
       </rich:columns>
       </rich:dataTable>
       </h:form>
      </f:view>
      </body>
      
      </html>
      
      


      Backbean code :

      
      import java.util.Arrays;
      import java.util.List;
      
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.log.Log;
      import org.jboss.seam.log.Logging;
      
      @Name("testBean")
      @Scope(ScopeType.SESSION)
      public class Test {
       private static final Log log=Logging.getLog(Test.class);
      
       public List<String> getColumns(){
       log.info("getColumns");
       return Arrays.asList(new String[]{"Col1","Col2","Col3","Col4"});
       }
      
       public List<List<String>> getRows(){
       log.info("getRows");
       return Arrays.asList(
       Arrays.asList(new String[]{"a","b","c","d"}),
       Arrays.asList(new String[]{"f","h","g","i"}),
       Arrays.asList(new String[]{"l","k","m","j"}),
       Arrays.asList(new String[]{"q","p","o","n"}));
       }
      }
      
      


      Environnement : Richfaces 3.2.2.GA / JSF 1.2_09 / JBoss 4.2.3.GA / SEAM 2.1.0.Snapshot.

      It would be very nice if you could do something...

      I have reproduced the problem with the new extendeddatatable component.

      Thanks in advance.

        • 1. Re: DATATABLE : filterBy + dynamic columns don't work
          Andrei Markavtsov Apprentice

          You should specify binding for 'sortOrder' attribute for each column.

          Example:

          <rich:columns value="#{testBean.columns}" var="column" index="ind" filterBy="#{row[ind]}" sortOrder="#{column.sortOrder}">
          <f:facet name="header">
           <h:outputText value="#{column}" />
           </f:facet>
           <h:outputText value="#{row[ind]}" />
           </rich:columns>
          
          
          To make it easier please add 'Column' class to example. Then put it's instances to array list for columns.
          
          Ex:
          
          public Column {
          String name;
          SortOrder sortOrder;
          .......
          }
          
          ....
          public List<String> getColumns(){
           log.info("getColumns");
           return Arrays.asList(new Column[] { new Column(), new Column() ....});
           }


          • 2. Re: DATATABLE : filterBy + dynamic columns don't work
            Nicolas Feybesse Newbie

            It doesn't change anything. The problem is the same :
            Filtering is applied on the last column for each inputtext.

            I don't unserstand why you are talking about the "sortOrder" attribute to make the "FilterBy" feature work. The problem isn't with "sortBy" feature but with "filterBy" feature.

            Perhaps I have forgotten something. Please have a look to my code :

            Code :

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml"
             xmlns:h="http://java.sun.com/jsf/html"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:a="http://richfaces.org/a4j"
             xmlns:c="http://java.sun.com/jstl/core"
             xmlns:rich="http://richfaces.org/rich">
            
            <body>
            <f:view>
             <h:form>
             <rich:dataTable sortMode="single" value="#{testBean.rows}" var="row">
             <rich:columns value="#{testBean.columns}" var="column" index="ind" filterBy="#{row[ind]}" sortOrder="#{column.sortOrder}">
             <f:facet name="header">
             <h:outputText value="#{column.name}" />
             </f:facet>
             <h:outputText value="#{row[ind]}" />
             </rich:columns>
             </rich:dataTable>
             </h:form>
            </f:view>
            </body>
            
            </html>
            


            and backbean :

            package com.genericsystem.application;
            
            import java.util.Arrays;
            
            @Name("testBean")
            @Scope(ScopeType.SESSION)
            public class Test {
             private static final Log log=Logging.getLog(Test.class);
            
             public List<Column> getColumns(){
             log.info("getColumns");
             return Arrays.asList(new Column[]{new Column("Col1"),new Column("Col2"),new Column("Col3"),new Column("Col4")});
             }
            
             public List<List<String>> getRows(){
             log.info("getRows");
             return Arrays.asList(
             Arrays.asList(new String[]{"a","b","c","d"}),
             Arrays.asList(new String[]{"f","h","g","i"}),
             Arrays.asList(new String[]{"l","k","m","j"}),
             Arrays.asList(new String[]{"q","p","o","n"}));
             }
            
             public class Column {
             private String name;
             private Ordering sortOrder=org.richfaces.model.Ordering.ASCENDING;
            
             public Column(String name){
             this.name=name;
             }
            
             public String getName(){
             return name;
             }
            
             public Ordering getSortOrder(){
             return sortOrder;
             }
            
             public void setSortOrder(Ordering sortOrder){
             this.sortOrder=sortOrder;
             }
            
            
             }
            }
            


            • 3. Re: DATATABLE : filterBy + dynamic columns don't work
              Andrei Markavtsov Apprentice

              Hi,

              Sorry for reply about sortOrder. It solves such problem with sorting but not with filtering.

              I added the issue to JIRA: https://jira.jboss.org/jira/browse/RF-4563.

              Thanks.