Version 4.10.0

hirondelle.web4j.action
Class ActionTemplateSearch

Object
  extended by hirondelle.web4j.action.ActionImpl
      extended by hirondelle.web4j.action.ActionTemplateSearch
All Implemented Interfaces:
Action

public abstract class ActionTemplateSearch
extends ActionImpl

Template for search screens.

Here, a search action has the following :

Search operations never require a redirect operation (since they do not edit the database).

Search operations have an interesting property : if you build a Model Object to validate and represent user input into the search form, then its getXXX methods can usually be made package-private, instead of public. The reason is that such Model Objects are usually not used by JSPs directly. If desired, such methods can safely return String instead of SafeText. (The Model Objects themselves cannot be made package-private, since the ModelFromRequest class works only with public classes.)


Field Summary
static RequestParameter SUPPORTED_OPERATION
          The operations supported by this template.
 
Fields inherited from class hirondelle.web4j.action.ActionImpl
DATA, ERRORS, ITEM_FOR_EDIT, ITEMS_FOR_LISTING, MESSAGES, USER_ID
 
Constructor Summary
protected ActionTemplateSearch(ResponsePage aForward, RequestParser aRequestParser)
          Constructor.
 
Method Summary
 ResponsePage execute()
          Template method.
protected abstract  void listSearchResults()
          Query the database, and place the results (usually) into request scope.
protected abstract  void validateUserInput()
          Validate items input by the user into a form.
 
Methods inherited from class hirondelle.web4j.action.ActionImpl
addError, addError, addError, addMessage, addMessage, addToRequest, addToSession, copyFromSessionToRequest, createSessionAndCsrfToken, endSession, getErrors, getExistingSession, getFromSession, getIdParam, getIdParams, getLocale, getLoggedInUserName, getMessages, getOperation, getOrderBy, getParam, getParamUnsafe, getRequestParser, getResponsePage, getTimeZone, getUserId, hasErrors, removeFromSession, setResponsePage
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUPPORTED_OPERATION

public static final RequestParameter SUPPORTED_OPERATION
The operations supported by this template.

The supported operations are :

The source of the Operation is described by ActionImpl.getOperation().

Constructor Detail

ActionTemplateSearch

protected ActionTemplateSearch(ResponsePage aForward,
                               RequestParser aRequestParser)
Constructor.

Parameters:
aForward - renders the result of the search
aRequestParser - passed to the superclass constructor.
Method Detail

execute

public ResponsePage execute()
                     throws AppException
Template method.

In order to clearly understand the operation of this method, here is the core of its implementation, with all abstract methods in italics :

    if (Operation.Show == getOperation() ){
      //default forward
    }
    else if ( Operation.Search == getOperation() ){
      validateUserInput();
      if( ! hasErrors() ){
        listSearchResults();
        if ( ! hasErrors() ){
          fLogger.fine("List executed successfully.");
        }
      }
    }
  

Specified by:
execute in interface Action
Specified by:
execute in class ActionImpl
Throws:
AppException

validateUserInput

protected abstract void validateUserInput()
                                   throws AppException
Validate items input by the user into a form.

The form is used to define the criteria for the search (if any).

Applies only for Operation.Search. If an error occurs, then addError must be called.

Throws:
AppException

listSearchResults

protected abstract void listSearchResults()
                                   throws AppException
Query the database, and place the results (usually) into request scope.

Throws:
AppException

Version 4.10.0

Copyright Hirondelle Systems. Published October 19, 2013 - User Guide - All Docs.