0 Replies Latest reply on Aug 13, 2008 6:55 AM by Stefanos Moshoyiannis

    DataScroller - setting the page

    Stefanos Moshoyiannis Newbie

      RichFaces 3.2.1
      Facelets 1.1.14
      JSF 1.2_09-b02-FCS

      I have a list of objects displayed by a datagrid which shows only one item at a time, and there is a datascroller to navigate the list.
      I have an actionlistener on a a4j:commandLink that adds an item to the list. When doing so I also want to control the datascroller to go to the last item of the list.
      What is the proper way to change the dataScroller's current item?
      Before migrating to 3.2, we were using RichFaces 3.1.5. In 3.1.5 I just did this:

      String newPage = String.valueOf(data.size());

      In 3.2 the setPage(String) method is deprecated, and the setPage(int) should be used instead. So I tried it but it only works on the first add. If I add again, then it remains on page 2.

      I peeked a little in the code of UIDataScroller and I saw that the current page is retrieved from an attribute of the dataTable (SCROLLER_STATE_ATTRIBUTE).
      So instead of setting the page with setPage(int) I did this:
      dataGrid.getAttributes().put(UIDatascroller.SCROLLER_STATE_ATTRIBUTE, page);

      But this seems really unlikely to be the proper way. Any thoughts?