You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2009/03/18 15:29:16 UTC
svn commit: r755603 -
/incubator/click/trunk/click/examples/src/org/apache/click/examples/service/CustomerService.java
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;