click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r755603 - /incubator/click/trunk/click/examples/src/org/apache/click/examples/service/CustomerService.java
Date Wed, 18 Mar 2009 14:29:16 GMT
Author: sabob
Date: Wed Mar 18 14:29:16 2009
New Revision: 755603

URL: http://svn.apache.org/viewvc?rev=755603&view=rev
Log:
guard against row index overflowing

Modified:
    incubator/click/trunk/click/examples/src/org/apache/click/examples/service/CustomerService.java

Modified: incubator/click/trunk/click/examples/src/org/apache/click/examples/service/CustomerService.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/service/CustomerService.java?rev=755603&r1=755602&r2=755603&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/service/CustomerService.java
(original)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/service/CustomerService.java
Wed Mar 18 14:29:16 2009
@@ -185,13 +185,18 @@
     }
 
     public List getCustomersForPage(int offset, int pageSize) {
-        SelectQuery query = new SelectQuery(Customer.class);
-        query.setPageSize(pageSize);
-        List list = performQuery(query);
+        List list = getCustomers();
 
         List pageList = new ArrayList(pageSize);
         for (int i = 0; i < pageSize; i++) {
-            pageList.add(list.get(offset + i));
+            // Increment row index with the offset
+            int rowIndex = offset + i;
+
+            // Guard against rowIndex that moves past the end of the list
+            if (rowIndex >= list.size()) {
+                break;
+            }
+            pageList.add(list.get(rowIndex));
         }
 
         return pageList;



Mime
View raw message