Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Cannot Reproduce
-
Affects Version/s: 1.1
-
Fix Version/s: 1.1.1
-
Component/s: Tag Library
-
Labels:None
-
Application server:JBoss 4.0.3SP1
Description
_display:table name="requestScope.purchaseItems_list" class="tab" pagesize="6"_
I have 2 tables underneath each other in a data mining-like web application.
The tables resides in different JSP fragment files that are included from a main JSP page.
If the bottom table are sent an empty list, displaytag crashes (but only if the pagesize attribute exist in the JSP).
- if the bottom list contains data, everything is OK
- if the bottom list JSP doesn't use the pagesize="x" attribute, everything is OK
Example (Bottom list is empty, and pagesize="6"):
-results in this stack trace:
15:16:59,075 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.IndexOutOfBoundsException: fromIndex = -6
at java.util.SubList.<init>(AbstractList.java:703)
at java.util.RandomAccessSubList.<init>(AbstractList.java:861)
at java.util.AbstractList.subList(AbstractList.java:570)
at org.displaytag.pagination.SmartListHelper.getListForPage(SmartListHelper.java:219)
at org.displaytag.pagination.SmartListHelper.getListForCurrentPage(SmartListHelper.java:200)
at org.displaytag.tags.TableTag.setupViewableData(TableTag.java:1525)
at org.displaytag.tags.TableTag.doEndTag(TableTag.java:1198)
at org.apache.jsp.list.PurchaseItems_jsp._jspService(org.apache.jsp.list.PurchaseItems_jsp:696)
From debugging SmartListHelper:
line 166:
return (pageNumber - 1) * this.pageSize;
line 217-219:
int firstIndex = getFirstIndexForPage(pageNumber);
int lastIndex = getLastIndexForPage(pageNumber);
return this.fullList.subList(firstIndex, lastIndex + 1);
When line 217 call line 166, and there are no pages (pageNumber=0), the returned index is (-1 * 'the defined pagesize from JSP'),
which results in the stack trace above
I have 2 tables underneath each other in a data mining-like web application.
The tables resides in different JSP fragment files that are included from a main JSP page.
If the bottom table are sent an empty list, displaytag crashes (but only if the pagesize attribute exist in the JSP).
- if the bottom list contains data, everything is OK
- if the bottom list JSP doesn't use the pagesize="x" attribute, everything is OK
Example (Bottom list is empty, and pagesize="6"):
-results in this stack trace:
15:16:59,075 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.IndexOutOfBoundsException: fromIndex = -6
at java.util.SubList.<init>(AbstractList.java:703)
at java.util.RandomAccessSubList.<init>(AbstractList.java:861)
at java.util.AbstractList.subList(AbstractList.java:570)
at org.displaytag.pagination.SmartListHelper.getListForPage(SmartListHelper.java:219)
at org.displaytag.pagination.SmartListHelper.getListForCurrentPage(SmartListHelper.java:200)
at org.displaytag.tags.TableTag.setupViewableData(TableTag.java:1525)
at org.displaytag.tags.TableTag.doEndTag(TableTag.java:1198)
at org.apache.jsp.list.PurchaseItems_jsp._jspService(org.apache.jsp.list.PurchaseItems_jsp:696)
From debugging SmartListHelper:
line 166:
return (pageNumber - 1) * this.pageSize;
line 217-219:
int firstIndex = getFirstIndexForPage(pageNumber);
int lastIndex = getLastIndexForPage(pageNumber);
return this.fullList.subList(firstIndex, lastIndex + 1);
When line 217 call line 166, and there are no pages (pageNumber=0), the returned index is (-1 * 'the defined pagesize from JSP'),
which results in the stack trace above
Here's my patch for this issue.
The patch is tested (but not intensively yet...), and is a patch for version 1.1 of displaytag
regards
Knut Erik Ballestad