4 Replies Latest reply on Oct 13, 2009 1:06 PM by Christian Kölle

    data:table Easiest way to propagate Sorting to the EL-bound

    Christian Kölle Newbie


      this is my first post. I am new to richfaces, I used to work with tomahawk before. Thanks for Richfaces.

      I have not found a solution within 2 hours searching, so I would like to ask for help.

      I use a

      • rich:datatable

      • with column-headers.

      • The column-headers are specified with sorting-attributes.

      • Sorting works! If I click on one of the "sortable"-table headers, the visible transient table is sorted correctly.

        Nevertheless, the sorting is not propagated to the java.util.List which represents the source data, ie. the actually List bound to the table. I have not found any attribute like "sortPropagationToModell".

        So my question is: What is the easiest way to implement sort propagation to the modellist? Is there any way without patching the DataModel?

        Regards and Thanks in advance.

        • 1. Re: data:table Easiest way to propagate Sorting to the EL-bo
          Ilya Shaikovsky Master

          you should implement the dataModel properly as it shown at modifiable model sample tab at richfaces-demo (dataTable page).

          • 2. Re: data:table Easiest way to propagate Sorting to the EL-bo
            Christian Kölle Newbie

            Thanks for your quick reply.

            I tried the following:

            • I implemented a GenericListDataProvider which implements DataProvider[T]
            • I used a ExtendedTableDataModifiableModel which uses the GenericListDataProvider.

              It works somehow in an unwanted way. I still do not fully understand the concept.

              Originally I bound a List of MyObjetct-instances to the the table, somehow like:
               value="#{[EL-String pointing to ArrayList<MyObect> in a session-scoped bean]}"

              As I said before: The only feature missing was, that the sorting was not propagated to the original list ArrayList[MyObject].

              Now: I intend not to replace the ArrayList in be backingBean by the implementention of ExtendedTableDataModifiableModel as I do not want to have uses-dependencies to RichFaces-Components in that class. Nevertheless I might be prepared to change my philosophy.

              So far so good: Now I have a table definition like this:
               value="#{EL-String pointing to ExtendedTableDataModifiableModel<MyObect> in a session scoped bean}"

              The problems I have with that approach are

              • that clicking on the sortable headers is visually doing anything except for flipping the sort-icons..
              • If I update the list of MyObject-Instances within my datamodell, I have to call reset().
              • The DataProvider functions are only called once.

                So, I do not know, whether I am on the right track. Might it be a solution to make my ExtendedTableDataModifiableModel a request-scoped bean? The session scope might be responsible for the fact that the DataProvider-Functions are only called once.

            • 3. Re: data:table Easiest way to propagate Sorting to the EL-bo
              Konstantin Mishin Novice

              I cannot understand, why you use ExtendedTableDataModifiableModel. This model is used in ExtendedTableData. I have found bug in our description (https://jira.jboss.org/jira/browse/RF-7978). Maybe, it was case of misunderstanding. So your model class should extend ExtendedDataModel and additionally implement Modifiable interface. I think, that sources of org.richfaces.demo.modifiableModel.BaseModifiableHibernateDataModel will be useful for you.

              • 4. Re: data:table Easiest way to propagate Sorting to the EL-bo
                Christian Kölle Newbie

                Thank you very much for your support: Problem solved.

                In addition to the misunderstanding, I lost the original list-reference during page action. This is now fixed. And I think I finally understand the concept.

                I finally found the BaseModifiableHibernateDataModel sources and will take a look into it soon.

                Thanks and Regards