2 Replies Latest reply on Apr 15, 2010 1:41 AM by Werner Greßhoff

    Problem with <rich:datascroller> and ExtendedTableDataModel

    Werner Greßhoff Newbie



      I had problems with the <rich:datascroller> and dynamically loading data when accessing a new page in the table. I found a lot of tips about using (extending) ExtendedTableDataModel, so I provided my own DataProvider and put it in the construcor of ExtendedDataTableModel (just as in the samples which are included in the 3.3.3.Final sources). First page was shown properly, the others not! Though the navigation handles are correct, but the data shown is allways that of the first page. So I finally had a look in the source code and saw the problem: the walk-Method caches the data and reuses it without ever again checking the range!

      For my project, I reimplemented the walk-Method without any caching done:


          public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) throws IOException {
              int rowC = getRowCount();
              int firstRow = ((SequenceRange) range).getFirstRow();
              int numberOfRows = ((SequenceRange) range).getRows();
              if (numberOfRows <= 0) {
                  numberOfRows = rowC;
              int endRow = firstRow + numberOfRows;
              if (endRow > rowC) {
                  endRow = rowC;
              for (T item : loadData(firstRow, endRow)) {
                  Object key = getKey(item);
                  visitor.process(context, key, argument);


      A better solution would be using a cache and check the range...

      I hope this is useful for any others fighting with the rich:datascroller!


      Best wishes


      Werner Greßhoff