7 Replies Latest reply on Jun 22, 2009 5:57 AM by Ilya Shaikovsky

    Reset datascroller to page one?

    Björn Raupach Newbie

      Hi!

      I am having a problem with a datatable and an associated datascroller. There is a search field in my page. Once a user enters some text, an action listener is called which connects to the database and loads the objects matching to the search criteria in a java.util.List. This list is used as value in the rich:datatable.

      The user can paginate through the results with the datascroller. Everything works fine. But lets say the user scrolls to page 5 and then enters something new in the search field. The datascroller doesn't reset itself to page 1.

      I tried binding and .setPage(1) of UIDatascroller in the actionListener of the search field but it didn't work out.

      Any help would be most welcome!

        • 1. Re: Reset datascroller to page one?
          panky_p Novice

          On hitting new search do you reRender the datascroller?

          • 2. Re: Reset datascroller to page one?
            Steven De Groote Newbie

            Is that with a page refresh or an ajax request?

            It's interesting to see that my pager stays on the same page, even when doing a new page request. Upon that request, I make some logging:

            14:14:03,968 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:82 - beforePhase(APPLY_REQUEST_VALUES 2)
            14:14:03,968 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:84 - Start of repeater: 100
            14:14:03,968 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:85 - Pager position: 5
            14:14:03,968 WARN be.sofico.web.frmwrk.SiteConfig:96 - Config property enable_policy not found
            14:14:03,968 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:82 - beforePhase(PROCESS_VALIDATIONS 3)
            14:14:03,984 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:84 - Start of repeater: 100
            14:14:03,984 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:85 - Pager position: 5
            14:14:03,984 WARN be.sofico.web.frmwrk.SiteConfig:96 - Config property enable_policy not found
            14:14:03,984 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:82 - beforePhase(UPDATE_MODEL_VALUES 4)
            14:14:03,984 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:84 - Start of repeater: 100
            14:14:03,984 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:85 - Pager position: 5
            14:14:03,984 WARN be.sofico.web.frmwrk.SiteConfig:96 - Config property enable_policy not found
            14:14:03,984 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:82 - beforePhase(INVOKE_APPLICATION 5)
            14:14:03,984 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:84 - Start of repeater: 100
            14:14:03,984 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:85 - Pager position: 5
            14:14:03,984 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:264 - Reset pager to first page
            14:14:03,984 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:266 - Start of repeater: 0
            14:14:03,984 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:267 - Pager position: 5
            14:14:03,984 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:154 - loadItems()
            14:14:04,906 WARN be.sofico.web.frmwrk.SiteConfig:96 - Config property enable_policy not found
            14:14:04,953 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:82 - beforePhase(RENDER_RESPONSE 6)
            14:14:04,953 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:84 - Start of repeater: 0
            14:14:04,953 DEBUG be.sofico.web.mgbean.report.MasterDataDetail:85 - Pager position: 5
            


            So it was on page 5, I do a new search, and the pager of the results is still on page 5, even though the displayed results are of page 1 of my new search...

            ps: Resetting the pager as you can see in the log is done by:
            cmpTable.setFirst(0);
            cmpDataScroller.setPage(1);


            • 3. Re: Reset datascroller to page one?
              Björn Raupach Newbie

              Thanks Tomba. That was exactly the behaviour I had trouble with. The search uses a page refresh.

              cmpTable.setFirst(0);
              cmpDataScroller.setPage(1);
              


              This helps! Thanks a lot! I did only setPage(1) but forgot setFirst(0) on the datatable.

              • 4. Re: Reset datascroller to page one?
                Björn Raupach Newbie

                I had rejoiced too soon. Tomba your solution works but it sets the datascroller to the last page not the first.

                Let me explain the behaviour.

                Lets say after a search there are 10 possible pages each having n rows. If I click on page 7 and then search again and the search yields equal or less than n results, only one page is displayed and the datascroller is not displayed at all. This is fine. This is what I was looking for.

                However if my result yields 6 pages. Then the datascroller and the datatable display the last page. In my logs I find messages like this one:

                The requested page #26 isn't found in the model containing 2 pages. Paging is reset to page #2


                • 5. Re: Reset datascroller to page one?
                  Ilya Shaikovsky Master

                  you could just use page attribute bound to some bean property and reset it when needed. So you will not use component binding at all.

                  • 6. Re: Reset datascroller to page one?
                    Björn Raupach Newbie

                    Hi Ilya,

                    could you elaborate on this?

                    If I use the page attribute I get the initial behaviour. Calling the setter in my actionListener to 1 doesn't seem to have an effect at all. Its just ignored.



                    • 7. Re: Reset datascroller to page one?
                      Ilya Shaikovsky Master

                      which RF version used? Try this at 3.3.1