11 Replies Latest reply on May 13, 2008 5:59 PM by kjohnston

    Datascroller + Datatable + Paging + Filtering

    kjohnston

      We have a datatable that uses paging. We also have support for filtering in our datatable.

      We recently upgraded from 3.0.1 to 3.1.4. Everything was working fine in 3.0.1.

      What seems to be happening now is that the Datascroller is invoking code on the server in our data model differently - it calls isRowAvailable, which forces our data model to load, *before* the filter string has been bound to the backing bean. Because we cache our data page to avoid loading twice, by the time the filter string has been set, it is too late - the page has already been loaded by the earlier call from the Datascroller.

      Anyone else seen this problem?

      As a last resort - I thought I would simply pull out the values from the HTTP Request and set them just before we get the datamodel. But I don't see where the request values are being kept. The requestParameterMap is empty. Is there a way to pull out the request values from the Ajax request?



        • 1. Re: Datascroller + Datatable + Paging + Filtering
          kjohnston

          It is worse than I thought. It appears that when clicking on the data scroller control, the form fields in the containing form are not being bound at all to the backing bean. So the search text never gets set on the bean.

          • 2. Re: Datascroller + Datatable + Paging + Filtering
            kjohnston

            OK, I finally got things working again. Posting my discoveries here to help anyone else upgrading from an older version to 3.1.4 (I tried 3.1.5 - same issues).

            First some background. We are using a very simple data model - we subclass the javax.faces.model.DataModel. We do not cache any data in the session - we fetch the current page each time the model is invoked.

            It looks like the datascroller, when you change pages, no longer processes the other values in the form that it is included in - which included our search field. I worked around this by adding an a4j:actionparam inside the datascroller, and rebinding the search field.

            The next problem I hit was that that getRowCount was being called earlier than it was before in the JSF lifecycle, before our search field value was bound to the backing bean. The call to getRowCount caused our data model to load a page - but it was not the page from the correctly filtered set. I noticed that the getRowCount was called in the APPLY_REQUEST_VALUES and PROCESS_VALIDATIONS phases. Since our table doesn't have any editable components in it, I figured it was safe to avoid scanning the table in those phases. So I added in a PhaseTracker and now I simply return 0 in getRowCount during those two phases.

            • 3. Re: Datascroller + Datatable + Paging + Filtering
              lucab

              i have a problem with datascroller too. i have an inputText for search queries on top of a dataTable. Let's suppose user makes a query that produces more than one page results. Now let's suppose user move on page 2 to read the results. Now our user is satisfied and wants to make another query. Let's say this query is more precise and gives all the results in one page.What happens at this point is that datascroller is still positioned on the second page (from previous query) that now doesn't exist.
              How can i force the datascroller to reset on page 1 after every new query? using page attribute does not work. datascroller, after reRendering, will be placed on the last seen page, even if the page, after refresh, does not exist anymore. So, if we stick to my example the user will be presented an empty page with no results and no page numbers displayed by the datascroller. Pushing the fast back button will send user to the first (and only) page where he can see the results of his query. So, how to avoid the 'virtual' second page to show up?
              Is it a problem of reRendering or dataScroller is not supposed to work in a continously rerendered table? or i missed something?

              • 4. Re: Datascroller + Datatable + Paging + Filtering
                kjohnston

                What you can do is define an a4j:commandButton "search" with an action. Declare the scroller inside a managedbean.

                Bind your datascroller to the backing bean using the "binding" attribute of the datascroller.

                Then, inside the action for the search button, you can call scroller.setPage("1") to return the scroller to the first page.

                • 5. Re: Datascroller + Datatable + Paging + Filtering
                  lucab

                  that didn't work...:( datascroller does not update itself corretly. even with binding. a bug?

                  • 6. Re: Datascroller + Datatable + Paging + Filtering
                    ilya_shaikovsky

                    we already know about sorting and filtering together with padding problems.

                    http://jira.jboss.com/jira/browse/RF-2815

                    just vote and please be patient.

                    • 7. Re: Datascroller + Datatable + Paging + Filtering
                      kjohnston

                      Are you re-rendering the datascroller? What version are you on?

                      • 8. Re: Datascroller + Datatable + Paging + Filtering
                        lucab

                        i'm rerendering the entire datatable to which the datascroller is attached (datascroller is included in a facet:header). Should i rerender explicitly datascroller too?

                        • 9. Re: Datascroller + Datatable + Paging + Filtering
                          lucab

                          sorry for the double post but there's no edit button and in the previuos post i forget to say which version of rich faces i'm using: 3.2.0 GA

                          • 10. Re: Datascroller + Datatable + Paging + Filtering
                            kjohnston

                            Interesting - our datascroller is not inside the table - it is outside, so yes we are explicity re-rendering. Perhaps that is why it still works for us.

                            • 11. Re: Datascroller + Datatable + Paging + Filtering
                              kjohnston

                              Update! To maintain the same behavior in the datascroller, all you have to do is add ajaxSingle=false to the datascroller.

                              See http://www.jboss.com/index.html?module=bb&op=viewtopic&t=103996