PAJES 2.3.9

org.pajes.db.entity
Class PagingLister

java.lang.Object
  extended byorg.pajes.db.entity.MaintenanceDisplayElement
      extended byorg.pajes.db.entity.Lister
          extended byorg.pajes.db.entity.PagingLister
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
DefaultLister

public abstract class PagingLister
extends Lister

Abstract super-class of all classes that create a Paje with a list of Entity objects, that support showing a subset of all Entity objects and paging through the subsets.

All sub-classes MUST have a no-parameter constructor.


Field Summary
static java.lang.String FIRST_LIST_VALUE
          The value ("f") of the LIST_PARAMETER that indicates that the request is to display the first page of the list.
static java.lang.String LAST_LIST_VALUE
          The value ("l") of the LIST_PARAMETER that indicates that the request is to display the last page of the list.
static java.lang.String LIST_PARAMETER
          The name ("_l_") of the request parameter that determines which subset of the Entity objects will be displayed on this invocation.
static java.lang.String NEXT_LIST_VALUE
          The value ("n") of the LIST_PARAMETER that indicates that the request is to display the next page of the list.
static java.lang.String PREVIOUS_LIST_VALUE
          The value ("p") of the LIST_PARAMETER that indicates that the request is to display the previous page of the list.
static java.lang.String ROWS_PARAMETER
          The name ("rows_parameter") of the request parameter that determines the number of Entity objects will be displayed on a page.
 
Fields inherited from class org.pajes.db.entity.Lister
SEARCH_ATTRIBUTE_SUFFIX, SEARCH_PARAMETER, SEARCH_PARAMETER_VALUE, SORT_ATTRIBUTE_SUFFIX, SORT_PARAMETER
 
Constructor Summary
PagingLister()
           
 
Method Summary
protected  int getFirstIndex()
          Returns the index in the result set of the first Entity to be displayed on the page.
protected  int getLastIndex()
          Returns the index in the result set of the last Entity displayed on the page.
protected  int getLastPageNumber()
          Convenience method to return the last page number.
protected  int getPageNumber()
          Convenience method to return the current page number.
protected  int getPageSize()
          Returns the maximum number of rows that will be displayed on each page.
protected  int getSetSize()
          Returns the number of rows in the total result set.
 void init(Manager manager, javax.servlet.ServletContext context)
          Initialises the PagingLister.
protected  Entity[] retrieveSet()
          Returns the set of Entity objects to be displayed in the list.
protected  void setFirstIndex(int first)
          Places the index in the result set of the first Entity displayed on the page into the HttpSession.
protected  void setPageSize(int rows)
          Sets the number of rows that will be displayed on each page.
 
Methods inherited from class org.pajes.db.entity.Lister
build, getAnchor, getBaseAnchor, getHeaderRowCount, getPaje, getRow, getScope, getSearchAttributeName, getSortAttributeName, init, onCell, onFirstRow, onLastRow, onRow, setNullDisplay, useQualifiedColumnNamesInScope
 
Methods inherited from class org.pajes.db.entity.MaintenanceDisplayElement
clone, getManager, getRequest, getServletContext, init, isInitialised, setRequest
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIRST_LIST_VALUE

public static final java.lang.String FIRST_LIST_VALUE
The value ("f") of the LIST_PARAMETER that indicates that the request is to display the first page of the list.

See Also:
Constant Field Values

LAST_LIST_VALUE

public static final java.lang.String LAST_LIST_VALUE
The value ("l") of the LIST_PARAMETER that indicates that the request is to display the last page of the list.

See Also:
Constant Field Values

LIST_PARAMETER

public static final java.lang.String LIST_PARAMETER
The name ("_l_") of the request parameter that determines which subset of the Entity objects will be displayed on this invocation.

The parameter value must be one of:

See Also:
Constant Field Values

NEXT_LIST_VALUE

public static final java.lang.String NEXT_LIST_VALUE
The value ("n") of the LIST_PARAMETER that indicates that the request is to display the next page of the list. If no LIST_PARAMETER is specified, this is the default.

See Also:
Constant Field Values

PREVIOUS_LIST_VALUE

public static final java.lang.String PREVIOUS_LIST_VALUE
The value ("p") of the LIST_PARAMETER that indicates that the request is to display the previous page of the list.

See Also:
Constant Field Values

ROWS_PARAMETER

public static final java.lang.String ROWS_PARAMETER
The name ("rows_parameter") of the request parameter that determines the number of Entity objects will be displayed on a page.

See Also:
Constant Field Values
Constructor Detail

PagingLister

public PagingLister()
Method Detail

init

public void init(Manager manager,
                 javax.servlet.ServletContext context)
          throws java.io.IOException
Initialises the PagingLister.

Sub-classes should not over-ride this method. Instead, sub-classes should over-ride the Lister.init(org.pajes.db.entity.Manager, javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest) method, which is called automatically by this method. If this method is over-rdden, the sub-class MUST call super.init(manager, context, request) to correctly iniitalise the lister.

Overrides:
init in class Lister
Parameters:
manager - the Manager that manages the Entity objects to be listed.
context - the ServletContext.
Throws:
java.io.IOException - if an IO exception occurs.

setFirstIndex

protected void setFirstIndex(int first)
                      throws java.lang.IndexOutOfBoundsException,
                             java.sql.SQLException
Places the index in the result set of the first Entity displayed on the page into the HttpSession.

Parameters:
first - the index in the result set of the first Entity to be displayed.
Throws:
java.lang.IndexOutOfBoundsException - if the argument is less than 1.
java.sql.SQLException - if an error occurs determining the set size.

getFirstIndex

protected int getFirstIndex()
                     throws java.sql.SQLException
Returns the index in the result set of the first Entity to be displayed on the page.

Returns:
the index in the result set of the first Entity to be displayed.
Throws:
java.sql.SQLException - if an error occurs determining the set size.

getLastIndex

protected int getLastIndex()
                    throws java.sql.SQLException
Returns the index in the result set of the last Entity displayed on the page.

Returns:
the index in the result set of the last Entity displayed.
Throws:
java.sql.SQLException - if an error occurs determining the set size.

getLastPageNumber

protected int getLastPageNumber()
                         throws java.sql.SQLException
Convenience method to return the last page number. The following formula is used:
   return (this.getSetSize() / this.getPageSize()) + 1;
 

Returns:
the last page number.
Throws:
java.sql.SQLException - if an error occurs determining the set size.

getPageNumber

protected int getPageNumber()
                     throws java.sql.SQLException
Convenience method to return the current page number. The following formula is used:
   return (this.getFirstIndex() / this.getPageSize()) + 1;
 

Returns:
the current page number.
Throws:
java.sql.SQLException - if an error occurs determining the set size.

setPageSize

protected void setPageSize(int rows)
Sets the number of rows that will be displayed on each page. If not specified, the default is 20 rows.

This default value may be over-ridden in the web application deployment descriptor. To set the default value, create a <context-param> with a <param-name> of org.pajes.db.entity.PagingLister.pageSize and a <param-value> containing the text. For example:

   <context-param>
       <param-name>org.pajes.db.entity.PagingLister.pageSize</param-name>
       <param-value>20</param-value>
   </context-param>
 

Parameters:
rows - The new page size value.

getPageSize

protected int getPageSize()
Returns the maximum number of rows that will be displayed on each page.

Returns:
the maximum number of rows on a page.

getSetSize

protected int getSetSize()
                  throws java.sql.SQLException
Returns the number of rows in the total result set.

Returns:
The number of rows in the total result set.
Throws:
java.sql.SQLException - if an error occurs determining the set size.

retrieveSet

protected Entity[] retrieveSet()
                        throws java.sql.SQLException
Returns the set of Entity objects to be displayed in the list.

The default implementation returns a maximum of getPageSize() entities that meet the scope, starting with the getFirstIndex(). It then updates the HttpSession with getFirstIndex().

Overrides:
retrieveSet in class Lister
Returns:
the array of Entity objects to be displayed in the list.
Throws:
java.sql.SQLException - if an error occurs retrieving the Entity objects.
See Also:
Lister.getScope()

PAJES 2.3.9

Copyright © 2002-2003 Viridian Pty Limited. All Rights Reserved.