myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Myfaces Wiki] Update of "WorkingWithLargeTables" by SimonKitching
Date Mon, 28 Nov 2005 04:34:16 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by SimonKitching:
http://wiki.apache.org/myfaces/WorkingWithLargeTables

The comment on the change is:
Bugfixes for example code

------------------------------------------------------------------------------
          }
  
          // invoke method on enclosing class
-         return fetchPage(startRow, pageSize);
+         page = fetchPage(startRow, pageSize);
+         return page;
      }
  
      /**
@@ -176, +177 @@

       */
      @Override
      public Object getRowData(){
-         DataPage<T> page = getPage();
+         if (rowIndex < 0) {
+             throw new IllegalArgumentException(
+                 "Invalid rowIndex for PagedListDataModel; not within page");
+         }
+ 
+         // ensure page exists; if rowIndex is beyond dataset size, then 
+         // we should still get back a DataPage object with the dataset size
+         // in it...
+         if (page == null) {
+             page = fetchPage(rowIndex, pageSize);
+         }
+ 
          int datasetSize = page.getDatasetSize();
          int startRow = page.getStartRow();
          int nRows = page.getData().size();
          int endRow = startRow + nRows;
          
-         if (rowIndex < 0) {
-             throw new IllegalArgumentException(
-                 "Invalid rowIndex for PagedListDataModel; not within page");
-         }
- 
          if (rowIndex >= datasetSize) {
              throw new IllegalArgumentException("Invalid rowIndex");
          }
@@ -272, +279 @@

  }}}
  
  The jsp pages are then trivial; by default the t:dataScroller will update the t:dataTable's
"first" property, and that's all that is needed because when the table
- asks the custom DataModel for the necessary rows callbacks to fetchPage will be made which
will fetch exactly the data required. No event listeners, action methods,
+ asks the custom !DataModel for the necessary rows callbacks to fetchPage will be made which
will fetch exactly the data required. No event listeners, action methods,
  or anything else is required as glue.
  
  === Other approaches ===

Mime
View raw message