4 Replies Latest reply on Dec 17, 2009 10:08 AM by Benno Markiewicz

    ExtendedDataTable not remembering sort

    Ryan Yoder Newbie

      I hope this is a dumb question but how do you make the ExtendedDataTable remember the current sort? If I navigate off the page and then back again, the sort order is lost. I tried tableState but that didn't work.
      I am left on the correct page because the rich:dataScroller uses my session backing bean to store the current page number and all my data is there since its also in session. I'm just losing the sort.


        • 1. Re: ExtendedDataTable not remembering sort
          Ilya Shaikovsky Master

          so you should implement your model which will do the work. modifiable model sample at richfaces-demo http://localhost:8080/richfaces-demo/richfaces/dataTable.jsf?c=dataTable&tab=modifiableDataModel

          • 2. Re: ExtendedDataTable not remembering sort
            Ilya Shaikovsky Master

            or even simplier - just bind sortOrder's of the columns and sortPriority to session bean property.

            • 3. Re: ExtendedDataTable not remembering sort
              Ryan Yoder Newbie

              Thanks for the reply. I don't use rich:columns, just multiple rich:column components under the datatable.
              I'm surprised the rich:extendedDataTable doesn't have a sortColumn property which you can bind to the session bean like the tomahawk control.
              Maybe if I bind the dataTable itself to the backing bean it will work but I have found that I often get duplicate ID errors if I bind a datatable.

              • 4. Solution: Remembering the sortOrder of a rich:dataTable
                Benno Markiewicz Newbie

                Regarding this problem: I could not figure out how to use sortPriority, but i found another solution.

                For a rich:dataTable in single-selection mode the sortorder can be saved by binding the sortOrder-property of each column (like ilya suggested).


                A working example: Here it is done via a session-scoped backing bean, which holds a map with entries for each column. (Note: external sorting is used here and therefore not shown)


                    <rich:dataTable id="#{id}resultTable"
                      <rich:column sortBy="#{dataItem.product0}"
                        <f:facet name="header">#{bundle['product0']}</f:facet>
                        <h:outputText value="#{dataItem.product[0].name}" />
                      <rich:column sortBy="#{dataItem.product1}"
                        <f:facet name="header">#{bundle['product1']}</f:facet>
                        <h:outputText value="#{dataItem.product[1].name}" />


                 * Holds information about which column is sorted.
                public class SortingStateHolder {
                  private final Map<String, String> order = new HashMap<String, String>() {
                      put("product0", "UNSORTED");
                      put("product1", "UNSORTED");
                   * @return the order
                  public Map<String, String> getOrder() {
                    return order;