org.hdpagination.web.action
Class AbstractPaginationAction

java.lang.Object
  extended by org.hdpagination.web.action.AbstractPaginationAction
All Implemented Interfaces:
PaginationAction
Direct Known Subclasses:
AbstractCommandPaginationAction

public abstract class AbstractPaginationAction
extends java.lang.Object
implements PaginationAction

A convenient abstract class allowing custom action to extend rather than implement PaginationAction interface directly.

Since:
1.0
Author:
Liangfeng Ren

Constructor Summary
AbstractPaginationAction()
           
 
Method Summary
 java.lang.String getAttributeName4Data()
          The name of attribute which holds the search result in the specified scope.
 java.lang.String getDataScope()
          The scope where the search result is to be stored.
 java.lang.String getForwardPath()
          The URL path to which it will forward after execution of query.
 java.lang.String getId()
          Identifier of each search processing Action instance.
 java.lang.String getInputPath()
          The URL of input page.
 int getPageSize()
          How many records should be displayed in one page
abstract  QueryCallback getQueryCallback(javax.servlet.http.HttpServletRequest request)
          Generate a QueryCallback instance based on request parameters.
 QueryTemplate getQueryTemplate()
          The query execution engine.
 SearchResultHandler getSearchResultHandler()
          The handler to deal with the search result.
 Validator getValidator()
          The validator to process the validation of input data before executing the search
 View getView()
          Get the view who is responsible for rendering page.
 boolean isCacheRecordsCount()
          Flag to indicate whether the count of total records should be cached to improve performance.
 void setAttributeName4Data(java.lang.String attributeName4Data)
          Set the name of attribute which holds the search result in the specified scope.
 void setCacheRecordsCount(boolean cacheRecordsCount)
          Flag to indicate whether the count of total records should be cached to improve performance.
 void setDataScope(java.lang.String dataScope)
          Set the scope where the search result is to be stored.
 void setForwardPath(java.lang.String forwardPath)
          Set the URL path to which it will forward after execution of query
 void setId(java.lang.String id)
          Set action identifier.
 void setInputPath(java.lang.String inputPath)
          Set the URL of input page.
 void setPageSize(int pageSize)
          Set how many records should be displayed in one page
 void setQueryTemplate(QueryTemplate queryTemplate)
          Set the query execution engine.
 void setSearchResultHandler(SearchResultHandler resultHandler)
          Set the handler to deal with the search result
 void setValidator(Validator validator)
          Set the validator to process the validation of input data before executing the search
 void setView(View view)
          Set the view who is responsible for rendering page.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPaginationAction

public AbstractPaginationAction()
Method Detail

getAttributeName4Data

public java.lang.String getAttributeName4Data()
Description copied from interface: PaginationAction
The name of attribute which holds the search result in the specified scope. The default attribute name is defined in Globals.QUERY_RESULT_KEY

Specified by:
getAttributeName4Data in interface PaginationAction
Returns:

getDataScope

public java.lang.String getDataScope()
Description copied from interface: PaginationAction
The scope where the search result is to be stored. Valid scope value includes 'request', 'session' and 'application'. By default,data is stored in 'request' scope.

Specified by:
getDataScope in interface PaginationAction
Returns:

getForwardPath

public java.lang.String getForwardPath()
Description copied from interface: PaginationAction
The URL path to which it will forward after execution of query. However, if the view used in PaginationAction (It depends on view property of PaginationAction or GlobalConfig) is TilesView or Tiles2View, it is interpreted as name of Tiles definition

Specified by:
getForwardPath in interface PaginationAction
Returns:
See Also:
PaginationAction.getView(), GlobalConfig.getView()

getInputPath

public java.lang.String getInputPath()
Description copied from interface: PaginationAction
The URL of input page. Like the property forwardPath, if the view used in PaginationAction (It depends on view property of PaginationAction or GlobalConfig) is TilesView or Tiles2View, it is interpreted as name of Tiles definition corresponding to the input page.

It's used for validation only. If validation fails it will forward back to input URL. Its default value is the same as forwardPath.

Specified by:
getInputPath in interface PaginationAction
Returns:
See Also:
PaginationAction.getView(), GlobalConfig.getView()

getId

public java.lang.String getId()
Description copied from interface: PaginationAction
Identifier of each search processing Action instance. It should be unique for each page or search functionality. The PaginationServlet relies on this property to match the action instance with coming request URL (ServletPath). Related Pagination Tags rely on it to retrieve corresponding pagination information (such as "number of total records", "page number of current page") from HttpSession which is recorded in HttpSession the first time the query was executed.

Specified by:
getId in interface PaginationAction
Returns:
Identifier of Action

getPageSize

public int getPageSize()
Description copied from interface: PaginationAction
How many records should be displayed in one page

Specified by:
getPageSize in interface PaginationAction
Returns:

getQueryTemplate

public QueryTemplate getQueryTemplate()
Description copied from interface: PaginationAction
The query execution engine. It can be OR-Mapping (e.g. Hibernate), JPA or particular Database JDBC engine. Currently it supports Hibernate2,Hibernate3,JPA,Oracle JDBC,MySql JDBC.

Specified by:
getQueryTemplate in interface PaginationAction
Returns:

setId

public void setId(java.lang.String id)
Set action identifier.

Parameters:
id -

setPageSize

public void setPageSize(int pageSize)
Set how many records should be displayed in one page

Parameters:
pageSize -

setForwardPath

public void setForwardPath(java.lang.String forwardPath)
Set the URL path to which it will forward after execution of query

Parameters:
forwardPath -

setInputPath

public void setInputPath(java.lang.String inputPath)
Set the URL of input page. It's used for validation only. If validation fails it will forward back to input URL. If inputPath is not set then the validation failed request will forward back to URL specified by forwardPath property.

Parameters:
inputPath -

setQueryTemplate

public void setQueryTemplate(QueryTemplate queryTemplate)
Set the query execution engine. It can be OR-Mapping (e.g. Hibernate), JPA or particular Database JDBC engine. Currently it supports Hibernate2,Hibernate3,JPA,Oracle JDBC,MySql JDBC.

Parameters:
queryTemplate -

setDataScope

public void setDataScope(java.lang.String dataScope)
Set the scope where the search result is to be stored. Valid scope value includes 'request', 'session' and 'application'. By default,data is stored in 'request' scope.

Parameters:
dataScope -

setAttributeName4Data

public void setAttributeName4Data(java.lang.String attributeName4Data)
Set the name of attribute which holds the search result in the specified scope. The default attribute name is defined in Globals.QUERY_RESULT_KEY

Parameters:
attributeName4Data -

getSearchResultHandler

public SearchResultHandler getSearchResultHandler()
Description copied from interface: PaginationAction
The handler to deal with the search result.

Specified by:
getSearchResultHandler in interface PaginationAction
Returns:

setSearchResultHandler

public void setSearchResultHandler(SearchResultHandler resultHandler)
Set the handler to deal with the search result

Parameters:
resultHandler -

getValidator

public Validator getValidator()
Description copied from interface: PaginationAction
The validator to process the validation of input data before executing the search

Specified by:
getValidator in interface PaginationAction
Returns:

setValidator

public void setValidator(Validator validator)
Set the validator to process the validation of input data before executing the search

Parameters:
validator -

getQueryCallback

public abstract QueryCallback getQueryCallback(javax.servlet.http.HttpServletRequest request)
Generate a QueryCallback instance based on request parameters. This returned callback instance finally will be executed by the back-end query engine. It's custom action class can instantiate its own QueryCallback instance based on passed request parameter values. The returned QueryCallback instance should match with the injected QueryTemplate instance as follows:

(1) JdbcQueryCallback matchs with all subclass of JdbcQueryTemplate

(2) HBN2QueryCallback matchs with Hibernate2QueryTemplate

(3) HBN3QueryCallback matchs with Hibernate3QueryTemplate

(4) JPAQueryCallback matchs with JPAQueryTemplate

Specified by:
getQueryCallback in interface PaginationAction
Returns:

getView

public View getView()
Description copied from interface: PaginationAction
Get the view who is responsible for rendering page. If null is returned, the view returned from the method GlobalConfig.getView() is used to render page.

Specified by:
getView in interface PaginationAction
Returns:

setView

public void setView(View view)
Set the view who is responsible for rendering page. The view is used by this Action only.

Parameters:
view -
See Also:
InternalResourceView, TilesView, Tiles2View

isCacheRecordsCount

public boolean isCacheRecordsCount()
Flag to indicate whether the count of total records should be cached to improve performance. It's not cached by default, which means total number of records is recounted against database when navigating to other pages or resorting the result

Specified by:
isCacheRecordsCount in interface PaginationAction
Returns:

setCacheRecordsCount

public void setCacheRecordsCount(boolean cacheRecordsCount)
Flag to indicate whether the count of total records should be cached to improve performance. It's not cached by default, which means total number of records is recounted against database when navigating to other pages or resorting the result

Parameters:
cacheRecordsCount -


Copyright © 2008 HDPagination All Rights Reserved.