Main Page

From Simple Paging (inactive) Wiki
Jump to: navigation, search



Simple paging is an easy as pie-support-lib for you to use anywhere you need to realize simple paging. I realized that paging is too trivial to use something heavyweight in some cases but on the other hand you do not want to make the same mistakes over and over.

Stuff you want to understand


First of all we need something that supplies data for the list we want to paginate. Theres an interface called SimplePagingDataProvider which you can implement clever (using caching or whatever). However, simple-paging ships an implementation of that interface called DumbestPossibleDataProvider so you dont have to worry about that if you dont care about performance.


Theres a pojo called SimplePagingObject. It provides all the information you will need in the view part (as totalPages, itemsPerPage, currentPage aso).


To get one of those objects you ask the SimplePagingFactory to build it for you. Here youll find all the paging-math (which is not a lot btw).


Well, given we have a java.util.list of anything. We would instantiate a data provider like this:

SimplePagingDataProvider dataProvider = new DumbestPossibleDataProvider(myListOfAnything);

Given we want to begin paging with item 1 and 5 items per page

SimplePagingObject pagingObject = SimplePagingFactory.createPagingObject(dataProvider, 5, 1);

You pass that pagingObject to your view and do something like that (or something smarter which i didnt come up with):

<portlet:renderURL var="pagingPreviousPage">
   <portlet:param name="page" value="${pagingObject.currentPage - 1}"/>
   <portlet:param name="ipp" value="${pagingObject.itemsPerPage}"/>
<portlet:renderURL var="pagingNextPage">
   <portlet:param name="page" value="${pagingObject.currentPage + 1}"/>
   <portlet:param name="ipp" value="${pagingObject.itemsPerPage}"/>
<c:if test="${pagingObject.currentPage > 1}">
  <a href="${pagingPreviousPage}" title="Go to previous page"><</a>
${pagingObject.displayFrom} - ${pagingObject.displayUntil} von ${pagingObject.totalItems}
<c:if test="${pagingObject.currentPage < pagingObject.totalPages}">
 <a href="${pagingNextPage}" title="Go to next page">></a>
<c:forEach items="${}" var="item">