ICEfaces
  1. ICEfaces
  2. ICE-6563

java.lang.IllegalArgumentException in DataPaginator

    Details

    • Assignee Priority:
      P2
    • Workaround Exists:
      Yes
    • Workaround Description:
      Hide
      Extend the DataPaginator and overwrite the broadcast methode with:
      @Override
      public void broadcast(FacesEvent event) throws AbortProcessingException {
      if (event instanceof PaginatorActionEvent) {
      PaginatorActionEvent scrollerEvent = (PaginatorActionEvent) event;
      UIData uiData = getUIData();
      if (uiData == null) {
      return;
      }

      int pageindex = scrollerEvent.getPageIndex();
      if (pageindex == -1) {
      String facet = scrollerEvent.getScrollerfacet();
      if (FACET_FIRST.equals(facet)) {
      gotoFirstPage();
      } else if (FACET_PREVIOUS.equals(facet)) {
      gotoPreviousPage();
      } else if (FACET_NEXT.equals(facet)) {
      gotoNextPage();
      } else if (FACET_FAST_FORWARD.equals(facet)) {
      gotoFastForward();
      } else if (FACET_FAST_REWIND.equals(facet)) {
      gotoFastRewind();
      } else if (FACET_LAST.equals(facet)) {
      gotoLastPage();
      }
      scrollerEvent.setPageIndex(getPageIndex());
      } else {
      int pageCount = getPageCount();
      if (pageindex > pageCount) {
      pageindex = pageCount;
      }
      if (pageindex <= 0) {
      pageindex = 1;
      }
      uiData.setFirst(uiData.getRows() * (pageindex - 1));
      if (isImmediate()) {
      //page links are not a UICommand. They are just elements, so
      //by now the pageindex has been changed, now this component
      //itself needs to call the renderResponse.
      getFacesContext().renderResponse();
      }
      }
      broadcastToActionListener(scrollerEvent);
      }
      }
      Show
      Extend the DataPaginator and overwrite the broadcast methode with: @Override public void broadcast(FacesEvent event) throws AbortProcessingException { if (event instanceof PaginatorActionEvent) { PaginatorActionEvent scrollerEvent = (PaginatorActionEvent) event; UIData uiData = getUIData(); if (uiData == null) { return; } int pageindex = scrollerEvent.getPageIndex(); if (pageindex == -1) { String facet = scrollerEvent.getScrollerfacet(); if (FACET_FIRST.equals(facet)) { gotoFirstPage(); } else if (FACET_PREVIOUS.equals(facet)) { gotoPreviousPage(); } else if (FACET_NEXT.equals(facet)) { gotoNextPage(); } else if (FACET_FAST_FORWARD.equals(facet)) { gotoFastForward(); } else if (FACET_FAST_REWIND.equals(facet)) { gotoFastRewind(); } else if (FACET_LAST.equals(facet)) { gotoLastPage(); } scrollerEvent.setPageIndex(getPageIndex()); } else { int pageCount = getPageCount(); if (pageindex > pageCount) { pageindex = pageCount; } if (pageindex <= 0) { pageindex = 1; } uiData.setFirst(uiData.getRows() * (pageindex - 1)); if (isImmediate()) { //page links are not a UICommand. They are just elements, so //by now the pageindex has been changed, now this component //itself needs to call the renderResponse. getFacesContext().renderResponse(); } } broadcastToActionListener(scrollerEvent); } }

      Description

      I use the dataPaginator with a panelSeries. The Data behind the panelSeries is a list, which im going to filter. It works fine until i do the filtering on a page >firstPage. I get a java.lang.IllegalArgumentException with a negative Value. I think the issue is in the DataPaginator.broadcast function.

      Thats the Code from your svn:
        177: } else {
        178: int pageCount = getPageCount();
        179: if (pageindex > pageCount) {
        180: pageindex = pageCount;
        181: } else if (pageindex <= 0) {
        182: pageindex = 1;
        183: }
        184: uiData.setFirst(uiData.getRows() * (pageindex - 1));

      In my case the pageCount is 0 and pageindex=12 so after the if,else if the pageIndex is 0. In mathematic words if uiData.getRows>0 and pageindex-1<0 the result will be negative.

      I think the solution is to change the code to:
        177: } else {
        178: int pageCount = getPageCount();
        179: if (pageindex > pageCount) {
        180: pageindex = pageCount;
        181: }
        182: if (pageindex <= 0) {
        183: pageindex = 1;
        184: }
        185: uiData.setFirst(uiData.getRows() * (pageindex - 1));

      Hopefully my solution is the right so you only have to change it shortly and we will be happy (especially me)

        Activity

        Hide
        Luiz Abrahao added a comment -

        Would someone be able to point me to the workaround until this is not fixed?
        Thank you

        Show
        Luiz Abrahao added a comment - Would someone be able to point me to the workaround until this is not fixed? Thank you
        Hide
        yip.ng added a comment -

        Applied and tested.

        Revision: 24854


        Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/datapaginator/DataPaginator.java

        Revision: 24855


        Modified : /icefaces2/branches/icefaces-2.0.x-maintenance/icefaces/compat/components/src/main/java/com/icesoft/faces/component/datapaginator/DataPaginator.java

        Show
        yip.ng added a comment - Applied and tested. Revision: 24854 Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/datapaginator/DataPaginator.java Revision: 24855 Modified : /icefaces2/branches/icefaces-2.0.x-maintenance/icefaces/compat/components/src/main/java/com/icesoft/faces/component/datapaginator/DataPaginator.java
        Hide
        Ken Fyten added a comment -

        Need to add this to 1.8 / icefaces/trunk also.

        Show
        Ken Fyten added a comment - Need to add this to 1.8 / icefaces/trunk also.
        Hide
        yip.ng added a comment -

        Revision: 24857


        Modified : /icefaces/trunk/icefaces/component/src/com/icesoft/faces/component/datapaginator/DataPaginator.java

        Show
        yip.ng added a comment - Revision: 24857 Modified : /icefaces/trunk/icefaces/component/src/com/icesoft/faces/component/datapaginator/DataPaginator.java

          People

          • Assignee:
            yip.ng
            Reporter:
            Eval Uate
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: