org.displaytag.pagination
Class SmartListHelper

java.lang.Object
  extended by org.displaytag.pagination.SmartListHelper
Direct Known Subclasses:
PaginatedListSmartListHelper

public class SmartListHelper
extends java.lang.Object

Utility class that chops up a List of objects into small bite size pieces that are more suitable for display.

This class is a stripped down version of the WebListHelper from Tim Dawson (tdawson@is.com)

Version:
$Revision: 1138 $ ($Author: fgiust $)
Author:
epesh, Fabrizio Giustina

Constructor Summary
protected SmartListHelper()
          Constructor that can be used by subclasses.
  SmartListHelper(java.util.List list, int fullSize, int itemsInPage, TableProperties tableProperties, boolean partialList)
          Creates a SmarListHelper instance that will help you chop up a list into bite size pieces that are suitable for display.
 
Method Summary
protected  int computedPageCount()
          Returns the computed number of pages it would take to show all the elements in the list given the pageSize we are working with.
 int getFirstIndexForCurrentPage()
          Returns the index into the master list of the first object that should appear on the current page that the user is viewing.
protected  int getFirstIndexForPage(int pageNumber)
          Returns the index into the master list of the first object that should appear on the given page.
protected  int getLastIndexForCurrentPage()
          Returns the index into the master list of the last object that should appear on the current page that the user is viewing.
protected  int getLastIndexForPage(int pageNumber)
          Returns the index into the master list of the last object that should appear on the given page.
 java.util.List getListForCurrentPage()
          Returns a subsection of the list that contains just the elements that are supposed to be shown on the current page the user is viewing.
protected  java.util.List getListForPage(int pageNumber)
          Returns a subsection of the list that contains just the elements that are supposed to be shown on the given page.
 java.lang.String getPageNavigationBar(Href baseHref, java.lang.String pageParameter)
          Returns a string containing the nagivation bar that allows the user to move between pages within the list.
 java.lang.String getSearchResultsSummary()
          Return the little summary message that lets the user know how many objects are in the list they are viewing, and where in the list they are currently positioned.
 void setCurrentPage(int pageNumber)
          Set's the page number that the user is viewing.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SmartListHelper

public SmartListHelper(java.util.List list,
                       int fullSize,
                       int itemsInPage,
                       TableProperties tableProperties,
                       boolean partialList)
Creates a SmarListHelper instance that will help you chop up a list into bite size pieces that are suitable for display.

Parameters:
list - List
fullSize - size of the full list
itemsInPage - number of items in a page (int > 0)
tableProperties - TableProperties

SmartListHelper

protected SmartListHelper()
Constructor that can be used by subclasses. Subclasses that use this constructor must also override all the public methods, since this constructor does nothing.

Method Detail

computedPageCount

protected int computedPageCount()
Returns the computed number of pages it would take to show all the elements in the list given the pageSize we are working with.

Returns:
int computed number of pages

getFirstIndexForCurrentPage

public int getFirstIndexForCurrentPage()
Returns the index into the master list of the first object that should appear on the current page that the user is viewing.

Returns:
int index of the first object that should appear on the current page

getLastIndexForCurrentPage

protected int getLastIndexForCurrentPage()
Returns the index into the master list of the last object that should appear on the current page that the user is viewing.

Returns:
int

getFirstIndexForPage

protected int getFirstIndexForPage(int pageNumber)
Returns the index into the master list of the first object that should appear on the given page.

Parameters:
pageNumber - page number
Returns:
int index of the first object that should appear on the given page

getLastIndexForPage

protected int getLastIndexForPage(int pageNumber)
Returns the index into the master list of the last object that should appear on the given page.

Parameters:
pageNumber - page number
Returns:
int index of the last object that should appear on the given page

getListForCurrentPage

public java.util.List getListForCurrentPage()
Returns a subsection of the list that contains just the elements that are supposed to be shown on the current page the user is viewing.

Returns:
List subsection of the list that contains the elements that are supposed to be shown on the current page

getListForPage

protected java.util.List getListForPage(int pageNumber)
Returns a subsection of the list that contains just the elements that are supposed to be shown on the given page.

Parameters:
pageNumber - page number
Returns:
List subsection of the list that contains just the elements that are supposed to be shown on the given page

setCurrentPage

public void setCurrentPage(int pageNumber)
Set's the page number that the user is viewing.

Parameters:
pageNumber - page number

getSearchResultsSummary

public java.lang.String getSearchResultsSummary()
Return the little summary message that lets the user know how many objects are in the list they are viewing, and where in the list they are currently positioned. The message looks like: nnn [item(s)] found, displaying nnn to nnn. [item(s)] is replaced by either itemName or itemNames depending on if it should be signular or plural.

Returns:
String

getPageNavigationBar

public java.lang.String getPageNavigationBar(Href baseHref,
                                             java.lang.String pageParameter)
Returns a string containing the nagivation bar that allows the user to move between pages within the list. The urlFormatString should be a URL that looks like the following: somepage.page?page={0}

Parameters:
baseHref - Href used for links
pageParameter - name for the page parameter
Returns:
String

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()


Copyright © 2002-2010 the Displaytag team. All Rights Reserved.