| java.lang.Object com.opensymphony.webwork.interceptor.MessageStoreInterceptor
MessageStoreInterceptor | public class MessageStoreInterceptor implements Interceptor(Code) | |
An interceptor to store
ValidationAware action's messages / errors and field errors into
Http Session, such that it will be retrieveable at a later stage. This allows the action's message /
errors and field errors to be available longer that just the particular http request.
In the 'STORE' mode, the interceptor will store the
ValidationAware action's message / errors
and field errors into Http session.
In the 'RETRIEVE' mode, the interceptor will retrieve the stored action's message / errors and field
errors and put them back into the
ValidationAware action.
The interceptor does nothing in the 'NONE' mode, which is the default.
The operation mode could be switched using :-
1] Setting the iterceptor parameter eg.
<action name="submitApplication" ...>
<interceptor-ref name="store">
<param name="operationMode">l;STORE</param>
</interceptor-ref>
<interceptor-ref name="defaultStack" />
....
</action>
2] Through request parameter (allowRequestParameterSwitch must be 'true' which is the default)
// the request will have the operation mode in 'STORE'
http://localhost:8080/context/submitApplication.action?operationMode=STORE
- allowRequestParameterSwitch - To enable request parameter that could switch the operation mode
of this interceptor.
- requestParameterSwitch - The request parameter that will indicate what mode this
interceptor is in.
- operationMode - The operation mode this interceptor should be in
(either 'STORE', 'RETRIEVE' or 'NONE'). 'NONE' being the default.
The following method could be overriden :-
- getRequestOperationMode - get the operation mode of this interceptor based on the request parameters
- mergeCollection - merge two collections
- mergeMap - merge two map
<action name="submitApplication" ....>
<interceptor-ref name="store">
<param name="operationMode">STORE</param>
</interceptor-ref>
<interceptor-ref name="defaultStack" />
<result name="input" type="redirect">applicationFailed.action</result>
<result type="dispatcher">applicationSuccess.jsp</result>
</action>
<action name="applicationFailed" ....>
<interceptor-ref name="store">
<param name="operationMode">RETRIEVE</param>
</interceptor-ref>
<result>applicationFailed.jsp</result>
</action>
With the example above, 'submitApplication.action' will have the action messages / errors / field errors stored
in the Http Session. Later when needed, (in this case, when 'applicationFailed.action' is fired, it
will get the action messages / errors / field errors stored in the Http Session and put them back into
the action.
author: tmjee version: $Date$ $Id$ |
Method Summary | |
protected void | after(ActionInvocation invocation, String result) Handle the storing of field errors / action messages / field errors, which is
done after action invocation, and the operationMode is in 'STORE'. | protected void | before(ActionInvocation invocation) Handle the retrieving of field errors / action messages / field errors, which is
done before action invocation, and the operationMode is 'RETRIEVE'. | public void | destroy() No operation. | public boolean | getAllowRequestParameterSwitch() Returns true if the request parameter (default to operationMode) is used to decide
which mode this interceptor should operates in. | public String | getOperationModel() | protected String | getRequestOperationMode(ActionInvocation invocation) Get the operationMode through request paramter, if allowRequestParameterSwitch
is 'true', else it simply returns 'NONE', meaning its neither in the 'STORE_MODE' nor
'RETRIEVE_MODE'. | public String | getRequestParameterSwitch() Returns the request parameter string that is used to determine the mode this
interceptor should operatoes in. | public void | init() No operatio9n. | public String | intercept(ActionInvocation invocation) Intercept the incomming request and store messages into HttpSession /
retrieve messages from HttpSession / do nothing
depending on the mode this interceptor is operating in. | protected Collection | mergeCollection(Collection col1, Collection col2) Merge col1 and col2 and return the composite
Collection . | protected Map | mergeMap(Map map1, Map map2) | public void | setAllowRequestParameterSwitch(boolean allowRequestParameterSwitch) If true allows request parameter (default to operationMode) to decide which mode
this interceptor should operates in. | public void | setOperationMode(String operationMode) | public void | setRequestParameterSwitch(String requestParameterSwitch) Set the request parameter string that is used to determine the mode this
interceptor should operates in . |
actionErrorsSessionKey | public static String actionErrorsSessionKey(Code) | | |
actionMessagesSessionKey | public static String actionMessagesSessionKey(Code) | | |
fieldErrorsSessionKey | public static String fieldErrorsSessionKey(Code) | | |
after | protected void after(ActionInvocation invocation, String result) throws Exception(Code) | | Handle the storing of field errors / action messages / field errors, which is
done after action invocation, and the operationMode is in 'STORE'.
Parameters: invocation - Parameters: result - throws: Exception - |
before | protected void before(ActionInvocation invocation) throws Exception(Code) | | Handle the retrieving of field errors / action messages / field errors, which is
done before action invocation, and the operationMode is 'RETRIEVE'.
Parameters: invocation - throws: Exception - |
destroy | public void destroy()(Code) | | No operation.
|
getAllowRequestParameterSwitch | public boolean getAllowRequestParameterSwitch()(Code) | | Returns true if the request parameter (default to operationMode) is used to decide
which mode this interceptor should operates in.
boolean |
getOperationModel | public String getOperationModel()(Code) | | Returns the operation mode this interceptor is operating in (valid values are)
- STORE
- RETRIEVE
- NONE (this is the default)
String |
getRequestOperationMode | protected String getRequestOperationMode(ActionInvocation invocation)(Code) | | Get the operationMode through request paramter, if allowRequestParameterSwitch
is 'true', else it simply returns 'NONE', meaning its neither in the 'STORE_MODE' nor
'RETRIEVE_MODE'.
String |
getRequestParameterSwitch | public String getRequestParameterSwitch()(Code) | | Returns the request parameter string that is used to determine the mode this
interceptor should operatoes in.
See Also: setAllowRequestParameterSwitch String |
init | public void init()(Code) | | No operatio9n.
|
intercept | public String intercept(ActionInvocation invocation) throws Exception(Code) | | Intercept the incomming request and store messages into HttpSession /
retrieve messages from HttpSession / do nothing
depending on the mode this interceptor is operating in.
String |
mergeCollection | protected Collection mergeCollection(Collection col1, Collection col2)(Code) | | Merge col1 and col2 and return the composite
Collection .
Parameters: col1 - Parameters: col2 - Collection |
mergeMap | protected Map mergeMap(Map map1, Map map2)(Code) | | Merge map1 and map2 and return the composite
Map
Parameters: map1 - Parameters: map2 - Map |
setAllowRequestParameterSwitch | public void setAllowRequestParameterSwitch(boolean allowRequestParameterSwitch)(Code) | | If true allows request parameter (default to operationMode) to decide which mode
this interceptor should operates in.
Parameters: allowRequestParameterSwitch - |
setOperationMode | public void setOperationMode(String operationMode)(Code) | | Set the operation mode this interceptor is operating in (valid values are)
- STORE
- RETRIEVE
- NONE (this is the default)
Parameters: operationMode - |
setRequestParameterSwitch | public void setRequestParameterSwitch(String requestParameterSwitch)(Code) | | Set the request parameter string that is used to determine the mode this
interceptor should operates in .
See Also: setAllowRequestParameterSwitch Parameters: requestParameterSwitch - |
|
|