2 Replies Latest reply on Oct 6, 2008 8:25 AM by Mohsen Saboorian

    SerializableDataModel and real database pagination

    Mohsen Saboorian Newbie

      Hi,

      I'm having problems with database pagination using rich:dataTable and my custom subclass of SerializableDataModel.

      I've written my custom datamodel based on this titorial:
      http://eclecticprogrammer.com/2008/06/25/sorting-and-paginating-in-the-database-with-richfaces/

      Unfortunately in the walk method of my custom datamodel, range parameter has always wrong values. range.getFirstRow is 0 and range.getRows is -1:

      walk(FacesContext context, DataVisitor visitor, Range range, Object argument)


      Any help on providing a real database pagination is highly appreciated.

      Mohsen.

        • 1. Re: SerializableDataModel and real database pagination
          Mohsen Saboorian Newbie

          I come up with <rich:dataTable> which internally instantiates and run the following method inside

           public void modify(List<FilterField> filterFields, List<SortField2> sortFields) {
           int rowCount = originalModel.getRowCount();
          
           if (rowCount > 0) {
           rowKeys = new ArrayList<Object>(rowCount);
           } else {
           rowKeys = new ArrayList<Object>();
           }
          
           FacesContext context = FacesContext.getCurrentInstance();
           try {
          
           originalModel.walk(context, new DataVisitor() {
           public void process(FacesContext context, Object rowKey,
           Object argument) throws IOException {
           originalModel.setRowKey(rowKey);
           if (originalModel.isRowAvailable()) {
           rowKeys.add(rowKey);
           }
           }
           }, new SequenceRange(0, -1),
           null);
           } catch (IOException e) {
           log.error(e.getMessage(), e);
           }
          
           filter(filterFields);
           sort(sortFields);
          
           }
          



          So my walk method is always called with a range which is explicitly new'd as SequenceRange(0, -1). Why is it so?

          Any hint?[img][/img]

          • 2. Re: SerializableDataModel and real database pagination
            Mohsen Saboorian Newbie

            Any help? I'm really get confused with this issue.