The dataset I display using PageableListView can get very big and keeping the whole dataset as a model would be very inefficient. Is it possible to load for example only the set of IDs first and then load only the objects that are to be displayed on the current page? I use Wicket+Spring+Hibernate/JPA. Or is there a better approach to paging in this case?
+2
A:
The usual way to deal with that (at least for me) would be to perform:
- a first query to count the items and deduce the number of pages to display
- subsequent queries using
Query#setFirstResult(int)
andQuery#setMaxResults(int)
for each page.
In Wicket, JPA, GlassFish and Java Derby or MySQL, the author shows precisely how to implement this approach using Wicket and a DataView
instead of PageableListView
(sample code provided).
Pascal Thivent
2010-10-21 16:25:00
+1: Basically the answer is to use DataView instead of PageableListView, but this blog entry indeed explains it well.
Don Roby
2010-10-21 21:59:15
@Don Thanks Don, you're right and I've clarified this point in my answer.
Pascal Thivent
2010-10-25 13:58:00