7 Replies Latest reply on Jan 29, 2008 5:22 PM by neilac333

    Using rich:datascroller With Hibernate Pagination on Server

      I prefer to handle all my pagination on the server with Hibernate, but I also want to use the <rich:datascroller> component. My Seam component "knows" the following information:

      1) The total number of page results
      2) The current page of results
      3) The desired number of results per page

      I am using rich:datascroller like this:

      <rich:datascroller for="searchResults"
      maxPages="100"
      pagesVar="#{searchAction.totalPages}"
      pageIndexVar="#{searchAction.currentPage}"
      rendered="#{not empty searchAction.searchResults}" />
      


      Yet when I try to use it, I am getting a scroller with no numbers for the pages and is disabled. It is like the scroller thinks that all the results are on this one page.

      How do I use rich:datascroller with the information I have in my Seam component to facilitate pagination?

      Thanks.

        • 1. Re: Using rich:datascroller With Hibernate Pagination on Ser
          amitev
          • 2. Re: Using rich:datascroller With Hibernate Pagination on Ser

            Thanks for the link, but I am not sure how to make this work in my case since I am using Seam. The data set for each page of information is represented by the @DataModel annotation in the managed component. If I were to try to create a different DataModel class entirely, I am not sure how to communicate that to Seam.

            Is there something particular in that thread you had in mind that I may have missed? Do you have experience with this approach in the Seam context?

            Thanks.

            • 3. Re: Using rich:datascroller With Hibernate Pagination on Ser
              ilya_shaikovsky

               

              <rich:datascroller pagesVar="pages" pageIndexVar="page">
               <f:facet name="pages">
               <h:outputText value="#{page}/#{pages}"/>
               </f:facet>
              </rich:datascroller>


              This scroller shows for me controls, number of pages and current page. To get count of pages - use the binding from first attribute of the table.
              Let me know if I understand you wrong.

              • 4. Re: Using rich:datascroller With Hibernate Pagination on Ser

                Thanks, Ilya. That helps me understand how to use some of the rich:datascroller attributes, but it still doesn't solve my problem. Let me try to explain better.

                I have a server-side Seam component that does the paging itself. For example, let's say I sarch for something that returns 43 results, and the user wants 10 results per page. The component knows that there are 5 total pages, that there are 10 results per page, and which results go with which page (page 0 has results 0-9 and page 4 has results 40-42 for example). The component also serves out the results one page at a time.

                All the rich:datascroller needs to know is that it is getting one page of perhaps many, but it can retrieve information about the entire result set (like total pages) from the Seam component.

                How can I do this with rich:datascroller and Seam? Judging from my research, it may not even be possible without essentially writing my own component.

                Thanks.

                • 5. Re: Using rich:datascroller With Hibernate Pagination on Ser

                  After doing some research, I found this:

                  http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4112998

                  It is true that this approach isn't the same as writing my own component, but man is it a lot of code!

                  Besides, even if I were to create my own DataModel, I am currently using the @DataModel and @DataModelSelection annotations in the context of a conversation, and I don't know how that process works with my own DataModel. I suppose I can outject my own DataModel like any other object, but how can I get the selection into the conversational context in an easy way?

                  It seems to me easier to just add my own navigation buttons and allow the user to page through the results that way. After all, most of the logic for handling that is in my Seam component.

                  I would appreciate any insight into some alternative approaches that others may have tried.

                  Also, will RichFaces 3.2 have a rich:datascroller that is capable of handling this out of the box?

                  • 6. Re: Using rich:datascroller With Hibernate Pagination on Ser

                    I wrote a class that extends SerializableDataModel, and I added a method that allows a client to provide the data set that will be wrapped in the form of a List. Unfortunately, the data set disappears between the submit of the search parameters and the rendering of the table and scroller. It certainly seems that a new instance of my SerializableDataModel is created. Is that so? Can anyone involved with the RichFaces project provide information on what the methods of SerializableDataModel actually do and when they are called in the lifecycle? The documentation is all but nonexistent.

                    Thanks.

                    • 7. Re: Using rich:datascroller With Hibernate Pagination on Ser

                      Another issue is that there are two considerations: defining the search parameters and then presenting the results. The example found at the Extended Data Model tab here:

                      http://livedemo.exadel.com/richfaces-demo/richfaces/dataTable.jsf

                      covers only the latter. But how do the search parameters get defined? It can't be the same component to handle both.

                      Or can it?