|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object hirondelle.web4j.action.ActionImpl hirondelle.web4j.action.ActionTemplateShowAndApply
public abstract class ActionTemplateShowAndApply
Template for "first show, then validate and apply" groups of operations.
A good example is a page allowing the user to change their preferences : from the point of view of each user, there is only one set of user preferences. Often, a single form can be used to allow editing of preferences. Here, there is no listing of multiple items.
There are two operations in such cases :
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 |
ActionTemplateShowAndApply(ResponsePage aForward,
ResponsePage aRedirect,
RequestParser aRequestParser)
Constructor. |
Method Summary | |
---|---|
protected abstract void |
apply()
Validate the user input, and then apply an edit to the database. |
ResponsePage |
execute()
Template method. |
protected abstract void |
show()
Show the input form. |
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 |
---|
public static final RequestParameter SUPPORTED_OPERATION
The supported operations are :
The source of the Operation is described byActionImpl.getOperation()
.
Constructor Detail |
---|
protected ActionTemplateShowAndApply(ResponsePage aForward, ResponsePage aRedirect, RequestParser aRequestParser)
aForward
- used for Operation.Show
operations, and also for failed
Operation.Apply
operations. This is the default response.aRedirect
- used for successful Operation.Apply
operations.aRequestParser
- passed to the superclass constructor.Method Detail |
---|
public ResponsePage execute() throws AppException
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() ){ show(); } else if ( Operation.Apply == getOperation() ){ validateUserInput(); if( ! hasErrors() ){ apply(); if ( ! hasErrors() ){ setResponsePage(fRedirect); } } }
execute
in interface Action
execute
in class ActionImpl
AppException
protected abstract void show() throws AppException
The form may or may not be populated.
AppException
protected abstract void validateUserInput() throws AppException
Applied to Operation.Apply
.
If an error occurs, then addError must be called.
AppException
protected abstract void apply() throws AppException
AppException
|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |