The dataset I display using Pag开发者_JAVA技巧eableListView 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?
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).
精彩评论