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

        Repository Revision Date User Message
        ICEsoft Public SVN Repository #24857 Tue Jun 21 14:43:38 MDT 2011 yip.ng ICE-6563: java.lang.IllegalArgumentException in DataPaginator.
        Files Changed
        Commit graph MODIFY /icefaces/trunk/icefaces/component/src/com/icesoft/faces/component/datapaginator/DataPaginator.java
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #24855 Tue Jun 21 12:18:57 MDT 2011 yip.ng ICE-6563: java.lang.IllegalArgumentException in DataPaginator.
        Files Changed
        Commit graph MODIFY /icefaces2/branches/icefaces-2.0.x-maintenance/icefaces/compat/components/src/main/java/com/icesoft/faces/component/datapaginator/DataPaginator.java
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #24854 Tue Jun 21 12:03:12 MDT 2011 yip.ng ICE-6563: java.lang.IllegalArgumentException in DataPaginator.
        Files Changed
        Commit graph MODIFY /icefaces2/trunk/icefaces/compat/components/src/main/java/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: