5 Replies Latest reply on Jan 19, 2009 7:43 AM by Ilya Shaikovsky

    Multiple regressions in extendeddatatable with dynamic colum

    Nicolas Feybesse Newbie

      Hi,

      I have problems with
      rich:columns and rich:extendeddatatable

      1) filterby doesnt''work anymore
      2) sortby doesn't work anymore
      3) Switch columns doesn't work and never stops if columns Id is defined

      1) & 2) are regressions

      You can see these problems in a little demo here :

      http://www.genericsystem.com/test/test9.gs

      Here is the 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 id="form">
       <rich:extendedDataTable value="#{test3.rows}" var="row" tableState="#{test3.tableState}">
       <rich:columns sortBy="#{row[ind]}" filterBy="#{row[ind]}" id="column-#{column.name}" value="#{test.columns}" var="column" index="ind">
       <f:facet name="header">
       <h:outputText value="#{column.name}" />
       </f:facet>
       <h:outputText value="#{row[ind]}" />
       </rich:columns>
       </rich:extendedDataTable>
       </h:form>
      </f:view>
      </body>
      
      </html>


      and backbean :

      package com.genericsystem.utils;
      
      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("test3")
      @Scope(ScopeType.SESSION)
      public class Test3 {
       private static final Log log=Logging.getLog(Test.class);
      
       private String tableState;
       private List<Column> columns=Arrays.asList(new Column[]{new Column("Col1"),new Column("Col2"),new Column("Col3")});
       private List<List<String>> rows=Arrays.asList(
       Arrays.asList( new String[]{"a","b","c"}),
       Arrays.asList( new String[]{"a","b","c"}),
       Arrays.asList( new String[]{"a","b","c"}),
       Arrays.asList(new String[]{"d","e","f"}));
      
       public List<Column> getColumns(){
       return columns;
       }
      
       public List<List<String>> getRows(){
       log.info("Call getRows !!!");
       return rows;
       }
      
      
       public String getTableState() {
       log.info("Get table state : "+tableState);
       return tableState;
       }
      
       public void setTableState(String tableState) {
       log.info("Set table state : "+tableState);
       this.tableState = tableState;
       }
      
       public class Column {
       private String name;
      
       public Column(String name){
       this.name=name;
       }
      
       public String getName(){
       return name;
       }
       }
      
      }
      


      NF

        • 1. Re: Multiple regressions in extendeddatatable with dynamic c
          Andrei Markavtsov Apprentice

          Hello,

          Thanks for the detailed code and link to sample.

          Since 3.3.0 columns component re-creates columns after each request. It means that created columns don't hold its states anymore.
          We need it because data model and bound attributes values can be changed on any time. And to prevent dublicated or unexpected columns we need re-create columns on each tag applying event.

          This is not a bug. Is just means that currently developer himself should take care about storing of column state.

          In your case you should provide binding for 'sortOrder' and 'filterValue' attributes to fire ordering/filtering features.

          See fixed code here:


          <h:form id="form">
           <rich:extendedDataTable value="#{test3.rows}" var="row" tableState="#{test3.tableState}">
           <rich:columns
           sortBy="#{row[ind]}"
           sortOrder="#{column.ordering}"
           filterBy="#{row[ind]}"
           filterValue="#{column.filterValue}"
           id="column-#{column.name}"
           value="#{test3.columns}"
           label="#{column.name}"
           var="column"
           index="ind">
           <f:facet name="header">
           <h:outputText value="#{column.name}" />
           </f:facet>
           <h:outputText value="#{row[ind]}" />
           </rich:columns>
           </rich:extendedDataTable>
           </h:form>
          
          



          and


          public class Test3 {
           private static final Log log = LogFactory.getLog(Test3.class);
          
           private String tableState;
           private List<Column> columns=Arrays.asList(new Column[]{new Column("Col1"),new Column("Col2"),new Column("Col3")});
           private List<List<String>> rows=Arrays.asList(
           Arrays.asList( new String[]{"a","b","c"}),
           Arrays.asList( new String[]{"a","b","c"}),
           Arrays.asList( new String[]{"a","b","c"}),
           Arrays.asList(new String[]{"d","e","f"}));
          
           public List<Column> getColumns(){
           return columns;
           }
          
           public List<List<String>> getRows(){
           log.info("Call getRows !!!");
           return rows;
           }
          
          
           public String getTableState() {
           log.info("Get table state : "+tableState);
           return tableState;
           }
          
           public void setTableState(String tableState) {
           log.info("Set table state : "+tableState);
           this.tableState = tableState;
           }
          
           public class Column {
           private String name;
           private Ordering ordering;
           private Object filterValue;
          
           public Column(String name){
           this.name=name;
           }
          
           public String getName(){
           return name;
           }
          
           /**
           * @return the ordering
           */
           public Ordering getOrdering() {
           return ordering;
           }
          
           /**
           * @param ordering the ordering to set
           */
           public void setOrdering(Ordering ordering) {
           this.ordering = ordering;
           }
          
           /**
           * @return the filterValue
           */
           public Object getFilterValue() {
           return filterValue;
           }
          
           /**
           * @param filterValue the filterValue to set
           */
           public void setFilterValue(Object filterValue) {
           this.filterValue = filterValue;
           }
          
          
           }
          
          }



          Check it please. All points [1) ,2) 3 )] work fine for me.

          • 2. Re: Multiple regressions in extendeddatatable with dynamic c
            Nicolas Feybesse Newbie

            Hi andrei.

            tests OK for 1) & 2)

            But 3) is still a problem.

            Ajax request never stops.

            I am talking about "switch columns with drag and drop".

            you can see your code run there :

            http://www.genericsystem.com/test/test9.gs

            NF

            • 3. Re: Multiple regressions in extendeddatatable with dynamic c
              Andrei Markavtsov Apprentice

              Hello,

              The first time I checked switching through the context menu, not through DnD.

              I've got the issue. But the solution just is more easier then I could think about :) Just change column id from 'column-#{column.name}' to 'column#{column.name}'. (Remove '-' symbol).

              Seems there is a bug in ExtendedTable which causes incorrect parsing of request params in case with '-'.

              I added your case in JIRA: https://jira.jboss.org/jira/browse/RF-5765.

              Thanks for this post.

              • 4. Re: Multiple regressions in extendeddatatable with dynamic c
                Nicolas Feybesse Newbie

                Hi Andrei,

                Without '-' character in column id, all seem ok.

                I have a last wish :

                ExtendedDatatable would become the ultimate table jsf component with this two new features :

                1) remove the default height of the table (if there are 3 rows, we don't want to display 400px). We often don't know rows count in advance, we need then a max-height behavior.

                2) add the scrollable feature (more difficult :) )

                NF