13 Replies Latest reply on Aug 29, 2008 9:46 AM by mail.micke

    DataScroller reset the current page

    maiky

      Hello,

      I try to explian my problem, sorry if you don't understand I'm bad in English.

      I've got a table with a datascroller to multipages.
      They are 10 lines per pages.

      In my table I've got a button to delet one line (on delete I rerender the table and the datascroller)

      If I've got 11 records and I go to the second page with the datascroller, I see 1 line.

      Then if I delete this line, i've got 10 records so 1 page.

      The datascroller show me 1 page, but it was on the page 2 so the table show no line.

      What can i do to reset the datascroller and redirect it to the first page ?

      Thks and sorry for my bad English.

        • 1. Re: DataScroller reset the current page
          amitev

          Currently the datascroller. You have to reset it yourself. You can do this with binding to the datatable and call dataTable.setFirst(0)

          • 2. Re: DataScroller reset the current page
            mail.micke


            A bit of a redundant post, but you also bind the datascroller and do:
            dataScroller.getDataTable().setFirst(0);

            :)

            • 3. Re: DataScroller reset the current page
              razwed4ik

              Hi Guys, I have the same problem.
              What do you mean with binding and call this setFirst() method. Can you give an example how to do this.

              If I have code like this:

              <rich:datascroller align="left" for="table" maxPages="10" />

              so how i can call this methode setFirst?


              Merry Christmas, bst rgrds

              • 4. Re: DataScroller reset the current page
                mail.micke

                Hi,
                what we mean is that you use a binding to an instance of the actual JSF ui component on the backing bean.

                Here you can choose to either have a binding to the data table, or like I suggested the data scroller.

                You do this by creating a property with the ui component on the backing bean like you would any other property, and then use the "binding" attribute in your xhtml/jsp markup. Really quite simple.

                Then what I do is call the setFirst method in an action which creates the data the datatable is displaying.

                Afraid I can't produce any code snippets now, late and on holiday. But if you need some I can digg some up for you later on.

                Cheers

                • 5. Re: DataScroller reset the current page
                  razwed4ik

                  Thanks Micke,

                  I think i understood, what u mean. Let you know, if I made it.

                  Happy holidays

                  • 6. Re: DataScroller reset the current page

                    I think the described behaviour should be default for datascroller.
                    I can't think of any situation when you don't want the datascroller to got to last page, when you just deleted the last item of the (previous) last page).

                    should we raise a feature request jira for this?

                    • 7. Re: DataScroller reset the current page

                      I just tried the workaround proposed in the other postings here.

                      Well, it works, but it feels very bad: This means that I must use UIDataScroller in each of my backing-beans and thus making my ejb-project dependant on the gui (richfaces libs).

                      does anyone know a better approach for this?

                      • 8. Re: DataScroller reset the current page
                        ljunior

                        I have a similar problem to solve. In my case I want to return to the page that the user was when he clicked the delete button. I added a scrollerListener to my dataScroller and I bind it to my backing bean. Should I use the setFirst method in this case too? Have anyone a example?

                        • 9. Re: DataScroller reset the current page

                          Does it work with the scrollerListener?
                          If not, getPageCount() and setPage() might help you.

                          • 10. Re: DataScroller reset the current page
                            ljunior

                            With the scrollerListener I might retrieve the last page selected by the user. What I couldn't yet is to return to that page. I tried to use the setPage method of DataScroller, however it doesn't work. Any other idea?

                            My code (somethings in Portuguese...):

                            public void scrollerListener(DataScrollerEvent evt){
                             System.out.println("New page: " + evt.getNewScrolVal() + " - Old page: " + evt.getOldScrolVal());
                             //((HtmlDatascroller)evt.getSource()).getDataTable().set
                             paginaAnterior = evt.getNewScrolVal();
                             }
                            
                             protected void voltarPaginaAnterior(){
                             System.out.println("Voltando para a página: " + paginaAnterior);
                             formDataScroller.setPage(paginaAnterior);
                             }
                            


                            • 11. Re: DataScroller reset the current page

                              that works for me (to reset the page to the last one):

                              public void checkPages(UIDatascroller ds) {
                               int pageCount = ds.getPageCount();
                               int pageIndex = ds.getPageIndex();
                               if (pageIndex > pageCount) {
                               ds.setPage(UIDatascroller.LAST_FACET_NAME);
                               }
                               }
                              


                              • 12. Re: DataScroller reset the current page
                                nbelaevski

                                That's been tracked as http://jira.jboss.com/jira/browse/RF-1133

                                The problem should be fixed in 3.2.0, please try it

                                • 13. Re: DataScroller reset the current page
                                  mail.micke

                                  I'm using 3.2.1 and had to resort to the page="#{some.el}" solution. Did this problem resurface?

                                  - micke