Details
Description
Ha, I'm surprised nobody has run into this one before. I have a table in my database with zero rows, and I'm using an <ice:dataPaginator/> in conjunction with an <ice:dataTable/>. When I try and view the page in the browser, I get an ArithmeticException on an integer divide-by-zero.
Here's the offending code on or about line 267 of DataPaginator.java:
if (uiData.getFirst() % rows > 0) {
pageIndex++;
}
As you can see, if rows=0, then a divide-by-zero will occur.
Here is my recommended fix (worked for me at least):
if (rows == 0) {
pageIndex = 1;
}
else if (uiData.getFirst() % rows > 0) {
pageIndex++;
}
Here's the offending code on or about line 267 of DataPaginator.java:
if (uiData.getFirst() % rows > 0) {
pageIndex++;
}
As you can see, if rows=0, then a divide-by-zero will occur.
Here is my recommended fix (worked for me at least):
if (rows == 0) {
pageIndex = 1;
}
else if (uiData.getFirst() % rows > 0) {
pageIndex++;
}
Issue Links
- is duplicated by
-
ICE-2154 DataPaginator.getPageIndex performs division by 0
- Closed
Activity
Neil Griffin
created issue -
Ken Fyten
made changes -
Field | Original Value | New Value |
---|---|---|
Fix Version/s | 1.6.2 [ 10111 ] | |
Fix Version/s | 1.7DR#3 [ 10112 ] | |
Assignee Priority | P1 | |
Assignee | Yip Ng [ yip.ng ] |
Repository | Revision | Date | User | Message |
ICEsoft Public SVN Repository | #15066 | Thu Nov 01 10:39:58 MDT 2007 | yip.ng | Changed to check for zero rows in data table to avoid division by zero. |
Files Changed | ||||
MODIFY
/icefaces/trunk/icefaces/component/src/com/icesoft/faces/component/datapaginator/DataPaginator.java
|
Repository | Revision | Date | User | Message |
ICEsoft Public SVN Repository | #15067 | Thu Nov 01 10:47:07 MDT 2007 | yip.ng | Changed to check for zero rows in data table to avoid division by zero. |
Files Changed | ||||
MODIFY
/icefaces/branches/icefaces-1.6/icefaces/component/src/com/icesoft/faces/component/datapaginator/DataPaginator.java
|
yip.ng
made changes -
Status | Open [ 1 ] | Resolved [ 5 ] |
Resolution | Fixed [ 1 ] |
Philip Breau
made changes -
Ken Fyten
made changes -
Priority | Major [ 3 ] | Minor [ 4 ] |
Ken Fyten
made changes -
Fix Version/s | 1.7 [ 10080 ] |
Ken Fyten
made changes -
Status | Resolved [ 5 ] | Closed [ 6 ] |
Assignee Priority | P1 | |
Assignee | Yip Ng [ yip.ng ] |
Changes applied as suggested.