Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Duplicate
-
Affects Version/s: 1.0
-
Fix Version/s: 1.1
-
Component/s: Paging/Sorting
-
Labels:None
Description
In the unfortunate event that the starting offset is the same as the number of items in the list, an empty page is shown.
This error occurs when the page number is saved in the session (using a custom RequestHelper) and the last item on the page is deleted. E.g. there are two pages and the last item on the second page is deleted. The pagenumber is still '2', but all items are shown on the first page, so the result is an empty list.
The fix is very easy. In the TableTag, the initParameters() method, the invalid page check should be this:
----------------------------------------------
// invalid page requested, go back to page one
if (start >= fullSize){
start = 0;
}
-----------------------------------------------
As you can see; when start == fullSize, start has to be changed as well, because there should be at least 1 item on each page. Theoretically this should work as well:
----------------------------------------------
// invalid page requested, go back to the previous page
while (start >= fullSize){
start = Math.max( start - this.pagesize, 0 );
}
-----------------------------------------------
Making it go to the previous page, instead of the first in the list.
This error occurs when the page number is saved in the session (using a custom RequestHelper) and the last item on the page is deleted. E.g. there are two pages and the last item on the second page is deleted. The pagenumber is still '2', but all items are shown on the first page, so the result is an empty list.
The fix is very easy. In the TableTag, the initParameters() method, the invalid page check should be this:
----------------------------------------------
// invalid page requested, go back to page one
if (start >= fullSize){
start = 0;
}
-----------------------------------------------
As you can see; when start == fullSize, start has to be changed as well, because there should be at least 1 item on each page. Theoretically this should work as well:
----------------------------------------------
// invalid page requested, go back to the previous page
while (start >= fullSize){
start = Math.max( start - this.pagesize, 0 );
}
-----------------------------------------------
Making it go to the previous page, instead of the first in the list.
----------------------------------------------
// invalid page requested, go back to the previous page
while (start >= fullSize){
start = Math.max( start - this.pagesize, 0 );
this.pageNumber--;
}
-----------------------------------------------