=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/paging/Paging.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/paging/Paging.java 2010-10-21 16:27:08 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/paging/Paging.java 2011-01-20 08:39:49 +0000 @@ -87,21 +87,23 @@ public int getStartPos() { - return currentPage <= 0 ? 0 : (currentPage - 1) * pageSize; + int startPos = currentPage <= 0 ? 0 : (currentPage - 1) * pageSize; + startPos = ( startPos > total ) ? total : startPos; + return startPos; } public int getEndPos() { - int endPos = (getStartPos() + getPageSize()) - 1; - endPos = endPos >= getTotal() ? getTotal() - 1 : endPos; + int endPos = getStartPos() + pageSize; + endPos = ( endPos > total ) ? total : endPos; return endPos; } public int getCurrentPage() { - if ( currentPage > total ) + if ( currentPage > getNumberOfPages() ) { - currentPage = total; + currentPage = getNumberOfPages(); } return currentPage; === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/paging/ActionPagingSupport.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/paging/ActionPagingSupport.java 2011-01-12 11:07:48 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/paging/ActionPagingSupport.java 2011-01-20 08:39:49 +0000 @@ -114,15 +114,10 @@ protected List getBlockElement( List elementList, int startPos, int pageSize ) { List returnList; - - try - { - returnList = elementList.subList( startPos, startPos + pageSize ); - } - catch ( IndexOutOfBoundsException ex ) - { - returnList = elementList.subList( startPos, elementList.size() ); - } + + int endPos = paging.getEndPos(); + + returnList = elementList.subList( startPos, endPos ); return returnList; }