2 Replies Latest reply on Apr 15, 2009 11:49 PM by Thomas W

    scrollableTable dynamic columns sorting broken

    Thomas W Newbie

      RF 3.3.0.GA

      Sorting works for static columns, but not with dynamic columns created with rich:columns.

      <rich:scrollableDataTable id="scrollableTestTable"
       value="#{EdtTestBean.rowIds}" var="rowId" selectionMode="multi"
       tableState="#{EdtTestBean.tableState}"
       selection="#{EdtTestBean.selection}" selectedClass="selected"
       rowClasses="tablerow1,tablerow2" columnsWidth="0*" width="100%"
       height="308px">
      
       <rich:column id="static1" label="Status" sortable="true"
       sortExpression="status-#{rowId}"
       sortIconAscending="dataTableAscIcon"
       sortIconDescending="dataTableDescIcon" styleClass="center">
       <f:facet name="header">FixedColumn1</f:facet>
       <h:outputText value="status-#{rowId}" />
       </rich:column>
      
       <rich:column id="static2" label="Status" sortable="true"
       sortExpression="status-#{rowId}"
       sortIconAscending="dataTableAscIcon"
       sortIconDescending="dataTableDescIcon" styleClass="center">
       <f:facet name="header">FixedColumn2</f:facet>
       <h:outputText value="status-#{rowId}" />
       </rich:column>
      
       <rich:columns id="#{col.name}" value="#{tableColumns}" var="col"
       index="colIndex" label="#{col.description}" sortable="true"
       sortExpression="#{EdtTestBean.getRow(rowId)[colIndex].value}"
       sortIconAscending="dataTableAscIcon"
       sortIconDescending="dataTableDescIcon">
       <f:facet name="header">
       <h:outputText value="#{col.description}" />
       </f:facet>
       <h:outputText value="#{EdtTestBean.getRow(rowId)[colIndex].value}" />
       </rich:columns>
      
      </rich:scrollableDataTable>
      



      Stacktrace when sorting on dynamic column:

      java.lang.IllegalArgumentException: null
      at javax.el.ListELResolver.coerce(ListELResolver.java:168)
      at javax.el.ListELResolver.getValue(ListELResolver.java:51)
      at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
      at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
      at org.jboss.el.parser.AstBracketSuffix.getValue(AstBracketSuffix.java:59)
      at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
      at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
      at org.richfaces.model.impl.expressive.ValueBindingExpression.evaluate(ValueBindingExpression.java:79)
      at org.richfaces.model.impl.expressive.ObjectWrapperFactory.wrapObject(ObjectWrapperFactory.java:189)
      at org.richfaces.model.ModifiableModel$RowKeyWrapperFactory.wrapObject(ModifiableModel.java:75)
      at org.richfaces.model.impl.expressive.ObjectWrapperFactory$2.convert(ObjectWrapperFactory.java:177)
      at org.richfaces.model.impl.expressive.ObjectWrapperFactory.convertList(ObjectWrapperFactory.java:138)
      at org.richfaces.model.impl.expressive.ObjectWrapperFactory.wrapList(ObjectWrapperFactory.java:175)
      at org.richfaces.model.ModifiableModel.sort(ModifiableModel.java:265)
      at org.richfaces.model.ModifiableModel.modify(ModifiableModel.java:234)


        • 1. Re: scrollableTable dynamic columns sorting broken
          Thomas W Newbie

          Looks like colIndex is not substituted in sortExpression (the way it would in the outputText child element). If I replace colIndex with a constant sorting works - though it doesn't make sense obviously.

          • 2. Re: scrollableTable dynamic columns sorting broken
            Thomas W Newbie

            The fix for this looks simple. In org.richfaces.taglib.ColumnsHandler, change line 161

            from
            if (ColumnsAttributes.FILTER_ATTRIBUTES.indexOf(name) != -1) {

            to
            if (ColumnsAttributes.SORT_ATTRIBUTES.indexOf(name) != -1 || ColumnsAttributes.FILTER_ATTRIBUTES.indexOf(name) != -1) {

            Unfortunately incorporating this tiny change would result in massive code duplication that would break even with 3.3.1 snapshot - ColumnsHandler operates with nested anonymous classes and private/package scope, almost looks as it it was designed to make customization impossible..

            Even though 3.3.1 has changes in this class, this issue is still present. Would it be possible to include this fix into the 3.3.1 release or at least record it in JIRA?