7 Replies Latest reply on Dec 28, 2006 6:53 AM by shane.bryzak

    paginating a datamodel

    ask4saif

      Is there any way we can paginate our datamodel inside a <h:dataTable>.
      Is there any kind of reference stuff for this problem.

      thank you in advance

        • 1. Re: paginating a datamodel
          melampo

          Hi.

          I have been looking for that some days ago, and I found the jenia4faces library.

          With the DataTools family components you can do theses things (I haven't try it at this momment, but with other jenia components I have no problems with seam, so I suposse that it will work).

          http://www.jenia.org

          • 2. Re: paginating a datamodel
            ask4saif

            Thanks alot man, I tried it and it worked fine. thanx again....

            But there is a little performace issue, I am using DataModel and i loads whole of the data in it from the DataBase. Now this data can be up to thousands of records. Now this raises the memory issue, the server may ran out of memory. how can i solve this issue.

            I mean it would be better if it get, suppose 100 records and populate it in the datamodel and on the jsf page it shows 10 records at a time. when we reach the 11th page then it fetches the next 100 records.

            Is it possible?

            Thanx again man for the reference and everything.

            • 3. Re: paginating a datamodel

              The Query API may help.

              http://java.sun.com/javaee/5/docs/api/javax/persistence/Query.html

              Query setFirstResult(int startPosition)
               Set the position of the first result to retrieve.
              
               Query setMaxResults(int maxResult)
               Set the maximum number of results to retrieve.




              • 4. Re: paginating a datamodel

                Look at EntityQuery in the Seam application framework. You can get a paginated query perfect for populating a datatable in just a few minutes.

                • 5. Re: paginating a datamodel
                  ask4saif

                  First of all thank you for your support, its very nice of you,

                  The scenario on which I am working is, I want pagination which i have been able to do with the jenia's library. And i want grid facility in it, which is provided by the seam by using the @DataModel and @DataModelSelection.

                  Now the only problem which I see in what i did is, the memory. Now my DataModel fetches the full resultset from the db which might get up to 1 million records. In this case how can i efficiently use my DataModel to fetch only chunks of records not full list.

                  the pagination of google search is great I wonder how can we do that in seam using the datamodel.

                  any advice which you can give, I will be gratefull

                  thank you in advance

                  • 6. Re: paginating a datamodel
                    ask4saif

                    Dear Norman Richards,

                    can you plz send me a sample code for the EntityQuery, or any hint. other than EntityQuery :) thanx

                    • 7. Re: paginating a datamodel
                      shane.bryzak

                      Take a look at the booking example, in particular HotelSearchingAction.