← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2664: Fix bug: Problem in jump tp specific page in Organisationunit.

 

------------------------------------------------------------
revno: 2664
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-01-20 15:39:49 +0700
message:
  Fix bug: Problem in jump tp specific page in Organisationunit.
modified:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/paging/Paging.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/paging/ActionPagingSupport.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== 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<T> getBlockElement( List<T> elementList, int startPos, int pageSize )
     {
         List<T> 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;
     }