ICEfaces
  1. ICEfaces
  2. ICE-2292

Divide by zero error in DataPaginator.java when zero rows exist in the model

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.7DR#2
    • Fix Version/s: 1.6.2, 1.7DR#3, 1.7
    • Component/s: None
    • Labels:
      None
    • Environment:
      trunk revision 15048 as of 10/30/2007

      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++;
              }

        Issue Links

          Activity

          Hide
          yip.ng added a comment -

          Changes applied as suggested.

          Show
          yip.ng added a comment - Changes applied as suggested.

            People

            • Assignee:
              Unassigned
              Reporter:
              Neil Griffin
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: