3 Replies Latest reply on May 29, 2009 3:52 AM by sebastianfiss

    Problem: PreSorting rich:table in composition by SortPriorit

      Hi,
      I have a rich:table with compositional columns and want to use the built-in sorting. Further, I want this table to be presorted when rendered the first time. To achieve this, I store sortPriority of the table and sortOrder of columns in a SessionBean.
      However, the table always sorts by the LAST column, even though it shows the arrow on the correct column.
      (Behavior similiar to my last Problem with Filtering the table using compositions, posted on JIRA https://jira.jboss.org/jira/browse/RF-7204 )


      I am using richfaces 3.3.1.GA, myfaces 1.2.5.

      My view:
      (test.testPriorities returns a List with one String "firstCol")

       <h:form>
       <rich:dataTable label="Table"
       value="#{test.testList}"
       sortPriority="#{test.testPriorities}"
       sortMode="single"
       rows="10"
       var="obj">
      
       <my:column title="FIRST"
       id="firstCol"
       sortBy="first">
       <t:outputText value="#{obj.first}"/>
       </my:column>
      
       <my:column title="SECOND"
       id="secondCol"
       sortBy="second">
       <t:outputText value="#{obj.second}"/>
       </my:column>
      
       <my:column title="THIRD"
       id="thirdCol"
       sortBy="third">
       <t:outputText value="#{obj.third}"/>
       </my:column>
      
       <my:column title="LAST"
       id="lastCol"
       sortBy="last">
       <t:outputText value="#{obj.last}"/>
       </my:column>
       </h:form>
      


      My column facelet composition:
      (test.testSortOrder returns a HashMap {firstCol=ASCENDING} )
       <ui:composition>
       <rich:column id="#{id}"
       sortBy="#{obj[sortBy]}"
       sortOrder="#{test.testSortOrder[id]}">
       <f:facet name="header">
       <t:outputText value="#{title}" />
       </f:facet>
       <ui:insert/>
       </rich:column>
       </ui:composition>
      


      Now, maybe you even want to look at my TestBean class (Scope: Session, managed Bean):
      private List<String> testPriorities;
       public List<String> getTestPriorities()
       {
       if(testPriorities == null)
       {
       testPriorities = new ArrayList<String>();
       testPriorities.add("firstCol");
       }
       return testPriorities;
       }
      
       private HashMap<String, String> testSortOrder;
       public HashMap<String, String> getTestSortOrder()
       {
       if(testSortOrder == null)
       {
       testSortOrder = new HashMap<String, String>();
       testSortOrder.put("firstCol", "DESCENDING");
       }
       return testSortOrder;
       }
      


      Once the table is rendered, the arrow appears on the "firstCol" and shows "ASCENDING", however the table is sorted by the LAST column.

      Can you help me on this problem? Thank you in advance!

      Note: Maybe also check the behavior when passing the sortOrder as a String from the view to the column composition, the table won't sort anymore at all.