0 Replies Latest reply on Jan 17, 2008 1:29 PM by gonzalad

    dataScroller : invoke_app dataScroller.getPageIndex returns

    gonzalad Apprentice

      Hello,

      I'm using rich:dataScroller.

      Datascroller updates the page number *after* INVOKE_APPLICATION phase is complete (or just after my action handler is called).

      If I want to know the page number requested, I must use an actionListener (DataScrollerEvent.getNewScrolVal()), I cannot just rely on calling dataTable.getFirst() which returns the old value.

      Is it a bug ?

      See UIDataScroller code :

      public void broadcast(FacesEvent event) throws AbortProcessingException {
       //-> this calls my actionHandler
       super.broadcast(event);
       //the pagination is here (should it be before my action handler ?
       if (event instanceof DataScrollerEvent) {
       DataScrollerEvent dataScrollerEvent = (DataScrollerEvent) event;
       setPage(dataScrollerEvent.getNewScrolVal());
      
       FacesContext context = FacesContext.getCurrentInstance();
       AjaxRendererUtils.addRegionByName(context, this, this.getId());
       AjaxRendererUtils.addRegionByName(context, this, this.getFor());
      
       setupReRender(context);
      
       MethodBinding scrollerListener = getScrollerListener();
       if (scrollerListener != null) {
       scrollerListener.invoke(context, new Object[]{event});
       }
       }
       }


      For instance : when I paginate to page 2, the following code just prints the previous rendered page number.

      I use the following code :
      public String testScroll() {
       System.out.println(pageIndex="+getDataScroller().getPageIndex());
      }


      with
      <rich:datascroller for="table"
       binding="#{reportAction.dataScroller}"
       action="#{reportAction.testScroll}" reRender="region"/>


      Thanks for your insight !