Datascroller and true pagination
francof Jul 29, 2008 11:14 AMHi
I am desperate here, I have been stuck on this for the last 2 weeks - I have time to kill right now but this is killing me :(
I did some custom changes with seam-gen to create an template with Richfaces datascroller for every list page. The problem I discovered later was that the datascroller was not really doing a true pagination and firing the entire query for every "next" page. Very costly, not something I would ever put in production and have a good night's sleep.
I am a newbie to Seam/Hibernate/Richfaces but not new to J2EE stuff.
This was perhaps a challenge I am not ready for yet. But I decided to give it a shot. I started looking at using a custom SerializableDataModel and found these many helpful posts on this topic.
http://www.seamframework.org/docDisplay_d.seam
http://eclecticprogrammer.com/2008/06/25/sorting-and-paginating-in-the-database-with-richfaces/
I used the approach documented in the latter post. Worked very well, with sorting too. But I had to be put my the datamodel in session scope for it to work.
I then encountered another issue - after a new search, the datascroller would not get reset. Let's say my first search gave me 20 rows and I had 10 rows per page, that would be 2 pages. when I did a new search resulting in either no data or 1 page of data, I would still see 2 pages.
Then I followed this
http://jboss.com/index.html?module=bb&op=viewtopic&t=127277
and bound my datascroller to my data table.
@Name("burstDataModel") @Scope(ScopeType.SESSION) public class BurstDataModel extends SerializableDataModel { --- --- @In(required=false) private BaseUIDatascroller datascrollerUI = null; --- --- public void search () { update(); datascrollerUI.getDatascroller().getDataTable().setFirst(0); } }
Search action would then call search method on datamodel above. Still no luck, the datascroller does not reset as expected.
The richfaces developers have put up a nice example how to do pagination using the extended data model. But it is in no way complete.
Then there are the critics of using the datascroller at all.
http://jboss.com/index.html?module=bb&op=viewtopic&t=139916
http://www.seamframework.org/Community/TroublesToUseDatascrollerAndExtendedDataModel
I implemented the Facelets tag in the 2nd post and it works great!
Then this guy shows how to reset the UIData in the model
http://solutionsfit.com/blog/2007/11/13/solution-using-seam-to-pagination-issue-with-jsf-on-datamodel-updates/
I did not try it, too raw for this stuff.
Richfaces developers:
Can you answer these questions ?
--------------------------------------------------------------------------------
Can the datascroller along with an extended model support true pagination ?
What scope should this model lie in ? -
session ? - overkill conversation - when should you start/stop the conversation ?
What scope should the data provider be in ?
How do you sync the datascroller to the data in the extended model ?
Is it not possible to have true paging built into the control itself ?
--------------------------------------------------------------------------------
I do not give up easily, but frankly I think I may have to concede defeat here!
Is there anyone who can post a complete working example for newbies ?
Thanks
Franco