Tuesday, 4 February 2014

Java: (Spring) Getting subset of a list for paged display

PagedListHolder - one of those Spring classes that you wish you've
been using for the past 10 years

Given a
1. list of items
2. page number and
3. number of items per page

Return the part of the list to be displayed on the page


PagedListHolder<PopularSearch> pagedListHolder = new
PagedListHolder<PopularSearch>(sourceList);
pagedListHolder.setPage(pageNumber);
pagedListHolder.setPageSize(itemCountPerPage);

List<PopularSearch> tmp = pagedListHolder.getPageList();

No comments: