5 Replies Latest reply on Mar 24, 2009 10:30 AM by Christoph Sauer

    Sorting doesn't affect session bean / isn't persistent

    Christoph Sauer Newbie

      This is my first post here so hi everyone!
      I'm really new to richfaces and web app development in general, so please talk slowly and clearly ;-)

      I have a problem regarding sorting of a multi-paged dataTable:
      I'm using rich:dataTable together with rich:columns and rich:datascroller:

      <h:form>
       <rich:dataTable value="#{AddressesModel.addressesTableData}"
       id="addressOverviewTable" var="address" columns="10"
       headerClass="addressesTableHeader" rowClasses="oddRow,evenRow" rows="10" reRender="addressTableDS">
       <rich:columns id="label#{index}" sortBy="#{address[index]}"
       value="#{AddressesModel.addressesTableLabels}" var="label"
       index="index">
       <f:facet name="header">
       <h:outputText value="#{label}" />
       </f:facet>
       <h:outputText value="#{address[index]}" />
       </rich:columns>
       <f:facet name="footer">
       <rich:datascroller id="addressTableDS" for="addressOverviewTable" maxPages="10"/>
       </f:facet>
       </rich:dataTable>
       </h:form>
      


      When I click on the sorting Icon of a column-header, the data of the complete table is sorted and the current page is displayed correctly. However, when I use the datascroller to get to the next page, the original unsorted data shows up again. Perhaps this is the intended behavior, but what I actually want is this: http://livedemo.exadel.com/richfaces-demo/richfaces/sortingFeature.jsf?c=sorting&tab=usage

      I think/hope I could get along on my own if only I could find the complete source for that demo. I downloaded GA 3.3.0 and (briefly) went through the samples but couldn't locate it.

      So, how can I achieve this? What do I have to configure or implement in order make the tables changes made through sorting persist throughout the session?

      Btw.Here's the configuration of my session bean, at the moment, I provide some testdata by manually filling an ArrayList in the init() method:
      <managed-bean>
       <managed-bean-name>AddressesModel</managed-bean-name>
       <managed-bean-class>
       test.addressbook.modelbean.AddressesModel
       </managed-bean-class>
       <managed-bean-scope>session</managed-bean-scope>
       <managed-property>
       <property-name>addressesTableLabels</property-name>
       <list-entries>
       <value-class>java.lang.String</value-class>
       <value>#{msgs.referenceColumnHeader}</value>
       <value>#{msgs.nameColumnHeader}</value>
       <value>#{msgs.nameExtColumnHeader}</value>
       <value>#{msgs.streetColumnHeader}</value>
       <value>#{msgs.houseNoColumnHeader}</value>
       <value>#{msgs.PostalCodeColumnHeader}</value>
       <value>#{msgs.cityColumnHeader}</value>
       <value>#{msgs.countryColumnHeader}</value>
       <value>#{msgs.nonPublicColumnHeader}</value>
       <value>#{msgs.adColumnHeader}</value>
       </list-entries>
       </managed-property>
       </managed-bean>
      


      public class AddressesModel implements Serializable{
      
      private static final long serialVersionUID = -3032793308402273197L;
      private ArrayList<String[]> addressesTableData;
      private ArrayList<String> addressesTableLabels;
      
      @PostConstruct
      public void init(){
       ArrayList<String[]> addresses = new ArrayList<String[]>();
      
       String[] tmp = new String[]{"012139","Nintendo","GmbH","Geo-Strasse","4","Fr","76312","Paris","false","false"};
       addresses.add(tmp);
      
       //...if you don't mind, I will skip the rest of the Arrays here
      
       this.addressesTableData = addresses;
      
      }
      
      public AddressesModel(){
      }
      
      public ArrayList<String> getAddressesTableLabels() {
       return addressesTableLabels;
      }
      public void setAddressesTableLabels(ArrayList<String> addressesTableLabels) {
       this.addressesTableLabels = addressesTableLabels;
      }
      
      public ArrayList<String[]> getAddressesTableData() {
       return addressesTableData;
      }
      
      public void setAddressesTableData(ArrayList<String[]> addresses){
       this.addressesTableData = addresses;
      }
      
      public void addAddress(String[] address) {
       addressesTableData.add(address);
      }
      
      
      
      }
      


      Thanks in advance for any advice on what I missed here ;-)

      best regards
      Chris

      P.S.: what am I expected to do with the doc folder of the release archive? Whats wrong with plain .pdf's or a html-doc? =D