|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.struts.chain.contexts.ContextWrapper
org.apache.struts.chain.contexts.ActionContextBase
public abstract class ActionContextBase
Provide an abstract but semi-complete implementation of ActionContext to serve as the base for concrete implementations.
The abstract
methods to implement are the accessors for the named states,
getApplicationScope, getRequestScope, and
getSessionScope.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
java.util.Map.Entry<K,V> |
| Field Summary | |
|---|---|
static java.lang.String |
ACTION_CONFIG_KEY
|
static java.lang.String |
ACTION_FORM_KEY
|
static java.lang.String |
ACTION_KEY
|
static java.lang.String |
CANCEL_KEY
|
static java.lang.String |
ERROR_ACTION_MESSAGES_KEY
Provide the default context attribute under which to store the ActionMessage cache for errors. |
static java.lang.String |
EXCEPTION_KEY
|
static java.lang.String |
FORWARD_CONFIG_KEY
|
static java.lang.String |
INCLUDE_KEY
|
static java.lang.String |
LOCALE_KEY
|
static java.lang.String |
MESSAGE_ACTION_MESSAGES_KEY
Provide the default context attribute under which to store the ActionMessage cache. |
static java.lang.String |
MESSAGE_RESOURCES_KEY
|
static java.lang.String |
MODULE_CONFIG_KEY
|
protected TokenProcessor |
token
Store the TokenProcessor instance for this Context. |
static java.lang.String |
TOKEN_KEY
Provide the default context attribute under which to store the token key. |
static java.lang.String |
TRANSACTION_TOKEN_KEY
Provide the default context attribute under which to store the transaction token key. |
static java.lang.String |
VALID_KEY
|
| Fields inherited from interface org.apache.struts.chain.contexts.ActionContext |
|---|
APPLICATION_SCOPE, REQUEST_SCOPE, SESSION_SCOPE |
| Constructor Summary | |
|---|---|
ActionContextBase()
Instantiate ActionContextBase, wrapping a default ContextBase instance. |
|
ActionContextBase(org.apache.commons.chain.Context context)
Instantiate ActionContextBase, wrapping the given Context. |
|
| Method Summary | |
|---|---|
void |
addActionMessages(java.lang.String key,
ActionMessages messages)
Add the given messages to a cache stored in this Context, under key. |
void |
addErrors(ActionMessages errors)
Append the given errors keys to an internal cache, creating the cache if one is not already present. |
void |
addMessages(ActionMessages messages)
Append the given messages keys to an internal cache, creating the cache if one is not already present. |
ActionForm |
findOrCreateActionForm(java.lang.String formName,
java.lang.String scopeName)
Using this ActionContext's default
ModuleConfig, return an existing ActionForm
in the specified scope, or create a new one and add it to the specified
scope. |
ActionForm |
findOrCreateActionForm(java.lang.String formName,
java.lang.String scopeName,
ModuleConfig moduleConfig)
In the context of the given ModuleConfig and this
ActionContext, look for an existing
ActionForm in the specified scope. |
java.lang.String |
generateToken()
Generate a new transaction token, to be used for enforcing a single request for a particular transaction. |
Action |
getAction()
Get the action which has been identified to be executed as part of processing this request. |
ActionConfig |
getActionConfig()
Get the ActionConfig which contains the details for processing this request. |
ActionForm |
getActionForm()
Get the ActionForm instance which will carry any data submitted as part of this request. |
abstract java.util.Map |
getApplicationScope()
Return a Map of Application scoped values. |
java.lang.Boolean |
getCancelled()
Indicate if the "cancel event" state is set for for this context, |
ActionMessages |
getErrors()
Retrieve error messages from an internal cache, creating an empty cache if one is not already present. |
java.lang.Exception |
getException()
Retrieve an exception which may have been caught by some code using this ActionContext, usually by an exception handler. |
java.lang.Boolean |
getFormValid()
Is the ActionForm for this context valid? This method does not actually perform form validation. |
ForwardConfig |
getForwardConfig()
Get the ForwardConfig which has been identified as the basis for view-processing. |
java.lang.String |
getInclude()
Get the include path which should be processed as part of processing this request. |
java.util.Locale |
getLocale()
Return the user's currently selected Locale. |
org.apache.commons.logging.Log |
getLogger()
Provide the currently configured commons-logging Log
instance. |
MessageResources |
getMessageResources()
Return the default message resources for the current module. |
MessageResources |
getMessageResources(java.lang.String key)
Return the specified message resources for the current module. |
ActionMessages |
getMessages()
Retrieve messages from an internal cache, creating an empty cache if one is not already present. |
ModuleConfig |
getModuleConfig()
Get the ModuleConfig which is operative for the current request. |
abstract java.util.Map |
getRequestScope()
Return a Map of request scoped values. |
java.util.Map |
getScope(java.lang.String scopeName)
Return the Map representing the scope identified by scopeName. |
abstract java.util.Map |
getSessionScope()
Return a Map of Session scoped values. |
protected java.lang.String |
getTokenGeneratorId()
|
boolean |
isTokenValid()
Indicate whether a transaction token for this context is valid. |
boolean |
isTokenValid(boolean reset)
Indicate whether a transaction token is stored in the "session" scope for this context, optionally clearing the token, so that the next check would return false. |
void |
release()
Signal to the instance that it will not be used any more, so that any resources which should be cleaned up can be cleaned up. |
void |
resetToken()
Clear any transactional token stored in the "session" scope for this context, so that the next check would return false. |
void |
saveActionMessages(java.lang.String key,
ActionMessages messages)
Save the given ActionMessages into the request scope under the given key, clearing the attribute if the messages are empty or null. |
void |
saveActionMessages(java.lang.String scopeId,
java.lang.String key,
ActionMessages messages)
Save the given messages into the map identified by the
given scopeId under the given key. |
void |
saveErrors(ActionMessages errors)
Save the given error messages to the internal cache, clearing any previous messages in the cache. |
void |
saveMessages(ActionMessages messages)
Save the given messages to the internal cache, clearing any previous messages in the cache. |
void |
saveMessages(java.lang.String scope,
ActionMessages messages)
Adapt a legacy form of SaveMessages to the ActionContext API by storing the ActoinMessages under the default scope. |
void |
saveToken()
Save a new transaction token in the "session" scope for this context, creating new resources, if needed. |
void |
setAction(Action action)
Set the action which has been identified to be executed as part of processing this request. |
void |
setActionConfig(ActionConfig config)
Set the ActionConfig class contains the details for processing this request. |
void |
setActionForm(ActionForm form)
Set the ActionForm instance which will carry any data submitted as part of this request. |
void |
setCancelled(java.lang.Boolean cancelled)
Set the "cancel event" state for this context. |
void |
setException(java.lang.Exception e)
Store an exception in this context for use by other handling code. |
void |
setFormValid(java.lang.Boolean valid)
Store the result of the validation of the Context's ActionForm. |
void |
setForwardConfig(ForwardConfig forward)
Set the ForwardConfig which should be used as the basis of the view segment of the overall processing. |
void |
setInclude(java.lang.String include)
Set the include path which should be processed as part of processing this request. |
void |
setLocale(java.util.Locale locale)
Set the user's currently selected Locale. |
void |
setLogger(org.apache.commons.logging.Log logger)
Set the commons-logging Log instance which should be
used to LOG messages. |
void |
setMessageResources(MessageResources messageResources)
Set the default message resources for the current module. |
void |
setModuleConfig(ModuleConfig config)
Set the ModuleConfig which is operative for the current request. |
| Methods inherited from class org.apache.struts.chain.contexts.ContextWrapper |
|---|
clear, containsKey, containsValue, entrySet, get, getBaseContext, isEmpty, keySet, put, putAll, remove, size, values |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.apache.struts.chain.contexts.ActionContext |
|---|
getParameterMap |
| Methods inherited from interface java.util.Map |
|---|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
| Field Detail |
|---|
public static final java.lang.String ACTION_KEY
Constants.ACTION_KEY,
Constant Field Valuespublic static final java.lang.String ACTION_CONFIG_KEY
,
Constant Field Valuespublic static final java.lang.String ACTION_FORM_KEY
Constants.ACTION_FORM_KEY,
Constant Field Valuespublic static final java.lang.String FORWARD_CONFIG_KEY
Constants.FORWARD_CONFIG_KEY,
Constant Field Valuespublic static final java.lang.String MODULE_CONFIG_KEY
Constants.MODULE_CONFIG_KEY,
Constant Field Valuespublic static final java.lang.String EXCEPTION_KEY
Constants.EXCEPTION_KEY,
Constant Field Valuespublic static final java.lang.String ERROR_ACTION_MESSAGES_KEY
Provide the default context attribute under which to store the ActionMessage cache for errors.
public static final java.lang.String MESSAGE_ACTION_MESSAGES_KEY
Provide the default context attribute under which to store the ActionMessage cache.
public static final java.lang.String MESSAGE_RESOURCES_KEY
Constants.MESSAGE_RESOURCES_KEY,
Constant Field Valuespublic static final java.lang.String INCLUDE_KEY
Constants.INCLUDE_KEY,
Constant Field Valuespublic static final java.lang.String LOCALE_KEY
Constants.LOCALE_KEY,
Constant Field Valuespublic static final java.lang.String CANCEL_KEY
Constants.CANCEL_KEY,
Constant Field Valuespublic static final java.lang.String VALID_KEY
Constants.VALID_KEY,
Constant Field Valuespublic static final java.lang.String TRANSACTION_TOKEN_KEY
public static final java.lang.String TOKEN_KEY
protected TokenProcessor token
| Constructor Detail |
|---|
public ActionContextBase(org.apache.commons.chain.Context context)
context - Context to wrappublic ActionContextBase()
| Method Detail |
|---|
public void release()
ActionContext
release in interface ActionContextpublic abstract java.util.Map getApplicationScope()
ActionContextReturn a Map of Application scoped values.
This is implemented in analogy with the Application scope in the Servlet API, but it seems reasonable to expect that any Struts implementation will have an equivalent concept.
The ultimate meaning of "application scope" is an implementation detail left unspecified by Struts.
getApplicationScope in interface ActionContextpublic abstract java.util.Map getRequestScope()
ActionContextReturn a Map of request scoped values. A request is
understood as the fundamental motivation for any particular instance of
an ActionContext.
This is implemented in analogy with the Request Context in the Servlet API, but it seems reasonable to expect that any Struts implementation will have an equivalent concept.
The ultimate meaning of "request scope" is an implementation detail left unspecified by Struts.
getRequestScope in interface ActionContextpublic abstract java.util.Map getSessionScope()
ActionContextReturn a Map of Session scoped values. A session is
understood as a sequence of requests made by the same user.
This is implemented in analogy with the Session scope in the Servlet API, but it seems reasonable to expect that any Struts implementation will have an equivalent concept.
The ultimate meaning of "session scope" is an implementation detail left unspecified by Struts.
getSessionScope in interface ActionContextpublic java.util.Map getScope(java.lang.String scopeName)
ActionContextscopeName. Implementations should support at minimum the
names associated with the constants APPLICATION_SCOPE,
SESSION_SCOPE, and REQUEST_SCOPE, but are
permitted to support others as well.
getScope in interface ActionContextscopeName - A token identifying a scope, including but not limited
to APPLICATION_SCOPE, SESSION_SCOPE,
REQUEST_SCOPE.
public void setAction(Action action)
ActionContextSet the action which has been identified to be executed as part of processing this request.
setAction in interface ActionContextpublic Action getAction()
ActionContextGet the action which has been identified to be executed as part of processing this request.
getAction in interface ActionContextpublic void setActionForm(ActionForm form)
ActionContextSet the ActionForm instance which will carry any data submitted as part of this request.
setActionForm in interface ActionContextform - The ActionForm instance to use with this requestpublic ActionForm getActionForm()
ActionContextGet the ActionForm instance which will carry any data submitted as part of this request.
getActionForm in interface ActionContextpublic void setActionConfig(ActionConfig config)
ActionContextSet the ActionConfig class contains the details for processing this request.
setActionConfig in interface ActionContextconfig - The ActionConfig class to use with this requestpublic ActionConfig getActionConfig()
ActionContextGet the ActionConfig which contains the details for processing this request.
getActionConfig in interface ActionContextpublic void setForwardConfig(ForwardConfig forward)
ActionContextSet the ForwardConfig which should be used as the basis of the view segment of the overall processing. This is the primary method of "communication" with the "view" sub-chain.
setForwardConfig in interface ActionContextforward - The ForwardConfig to use with this requestpublic ForwardConfig getForwardConfig()
ActionContextGet the ForwardConfig which has been identified as the basis for view-processing.
getForwardConfig in interface ActionContextpublic void setInclude(java.lang.String include)
ActionContextSet the include path which should be processed as part of processing this request.
setInclude in interface ActionContextinclude - The include path to be used with this requestpublic java.lang.String getInclude()
ActionContextGet the include path which should be processed as part of processing this request.
getInclude in interface ActionContextpublic java.lang.Boolean getFormValid()
ActionContextIs the ActionForm for this context valid? This method does not actually perform form validation. It is simply a holder property where processes which perform validation can store the results of the validation for other processes' benefit.
getFormValid in interface ActionContextBoolean.TRUE if the form passed validation;
Boolean.FALSE if the form failed validation; null
if the form has not yet been validatedpublic void setFormValid(java.lang.Boolean valid)
ActionContextStore the result of the validation of the Context's ActionForm.
setFormValid in interface ActionContextvalid - Whether the ActionForm for this request passes validationpublic ModuleConfig getModuleConfig()
ActionContextGet the ModuleConfig which is operative for the current request.
getModuleConfig in interface ActionContextpublic void setModuleConfig(ModuleConfig config)
ActionContextSet the ModuleConfig which is operative for the current request.
setModuleConfig in interface ActionContextconfig - The ModuleConfig to be used with this requestpublic java.lang.Exception getException()
ActionContextRetrieve an exception which may have been caught by some code using this ActionContext, usually by an exception handler.
getException in interface ActionContextpublic void setException(java.lang.Exception e)
ActionContextStore an exception in this context for use by other handling code.
setException in interface ActionContexte - An exception to be stored for handling by another memberpublic void addMessages(ActionMessages messages)
ActionContextAppend the given messages keys to an internal cache, creating the cache if one is not already present.
addMessages in interface ActionContextmessages - New ActionMessages to cachepublic void addErrors(ActionMessages errors)
ActionContextAppend the given errors keys to an internal cache, creating the cache if one is not already present.
addErrors in interface ActionContexterrors - New ActionMessages to cache as errorspublic ActionMessages getErrors()
ActionContextRetrieve error messages from an internal cache, creating an empty cache if one is not already present.
getErrors in interface ActionContextpublic ActionMessages getMessages()
ActionContextRetrieve messages from an internal cache, creating an empty cache if one is not already present.
getMessages in interface ActionContextpublic void saveErrors(ActionMessages errors)
ActionContextSave the given error messages to the internal cache, clearing any previous messages in the cache.
If the parameter is null or empty, the internal cache is removed.
saveErrors in interface ActionContexterrors - ActionMesssages to cache as errorspublic void saveMessages(ActionMessages messages)
ActionContextSave the given messages to the internal cache, clearing any previous messages in the cache.
If the parameter is null or empty, the internal cache is removed.
saveMessages in interface ActionContextmessages - ActionMesssages to cache
public void addActionMessages(java.lang.String key,
ActionMessages messages)
Add the given messages to a cache stored in this Context, under key.
key - The attribute name for the message cachemessages - The ActionMessages to add
public void saveActionMessages(java.lang.String key,
ActionMessages messages)
Save the given ActionMessages into the request scope under the given key, clearing the attribute if the messages are empty or null.
key - The attribute name for the message cachemessages - The ActionMessages to add
public void saveActionMessages(java.lang.String scopeId,
java.lang.String key,
ActionMessages messages)
Save the given messages into the map identified by the
given scopeId under the given key.
scopeId - key - messages -
public void saveMessages(java.lang.String scope,
ActionMessages messages)
Adapt a legacy form of SaveMessages to the ActionContext API by storing the ActoinMessages under the default scope.
saveMessages in interface ActionContextscope - The scope for the internal cachemessages - ActionMesssages to cachepublic void saveToken()
ActionContextSave a new transaction token in the "session" scope for this context, creating new resources, if needed.
saveToken in interface ActionContextpublic java.lang.String generateToken()
ActionContextGenerate a new transaction token, to be used for enforcing a single request for a particular transaction.
generateToken in interface ActionContextprotected java.lang.String getTokenGeneratorId()
public boolean isTokenValid()
ActionContextIndicate whether a transaction token for this context is valid.
A typical implementation will place a transaction token in the session" scope Map and a matching value in the "parameter" Map. If the "session" token does not match the "parameter" attribute, or the session token is missing, then the transactional token is deemed invalid.
isTokenValid in interface ActionContextpublic boolean isTokenValid(boolean reset)
ActionContextIndicate whether a transaction token is stored in the "session" scope for this context, optionally clearing the token, so that the next check would return false.
isTokenValid in interface ActionContextreset - On true, clear the transactional tokenpublic void resetToken()
ActionContextClear any transactional token stored in the "session" scope for this context, so that the next check would return false.
resetToken in interface ActionContextpublic java.lang.Boolean getCancelled()
ActionContextIndicate if the "cancel event" state is set for for this context,
getCancelled in interface ActionContextActionContextBase.CANCEL_KEYpublic void setCancelled(java.lang.Boolean cancelled)
ActionContextSet the "cancel event" state for this context.
setCancelled in interface ActionContextcancelled - On true, set the cancel event state to true. On false,
set the cancel event state to false.ActionContextBase.CANCEL_KEYpublic void setMessageResources(MessageResources messageResources)
ActionContextSet the default message resources for the current module.
setMessageResources in interface ActionContextpublic MessageResources getMessageResources()
ActionContextReturn the default message resources for the current module.
getMessageResources in interface ActionContextpublic MessageResources getMessageResources(java.lang.String key)
ActionContextReturn the specified message resources for the current module.
getMessageResources in interface ActionContextkey - The key specified in the <message-resources>
element for the requested bundlepublic void setLocale(java.util.Locale locale)
ActionContextSet the user's currently selected Locale.
setLocale in interface ActionContextlocale - The user's selected Locale to be set, or null to select
the server's default Localepublic java.util.Locale getLocale()
ActionContextReturn the user's currently selected Locale.
getLocale in interface ActionContextpublic org.apache.commons.logging.Log getLogger()
Provide the currently configured commons-logging Log
instance.
public void setLogger(org.apache.commons.logging.Log logger)
Set the commons-logging Log instance which should be
used to LOG messages. This is initialized at instantiation time but may
be overridden. Be advised not to set the value to null, as
ActionContextBase uses the logger for some of its own
operations.
public ActionForm findOrCreateActionForm(java.lang.String formName,
java.lang.String scopeName)
throws java.lang.IllegalAccessException,
java.lang.InstantiationException
Using this ActionContext's default
ModuleConfig, return an existing ActionForm
in the specified scope, or create a new one and add it to the specified
scope.
formName - The name attribute of our ActionFormscopeName - The scope identier (request, session)
java.lang.IllegalAccessException - If object cannot be created
java.lang.InstantiationException - If object cannot be createdthis.findOrCreateActionForm(String, String, ModuleConfig)
public ActionForm findOrCreateActionForm(java.lang.String formName,
java.lang.String scopeName,
ModuleConfig moduleConfig)
throws java.lang.IllegalAccessException,
java.lang.InstantiationException
In the context of the given ModuleConfig and this
ActionContext, look for an existing
ActionForm in the specified scope. If one is found, return
it; otherwise, create a new instance, add it to that scope, and then
return it.
formName - The name attribute of our ActionFormscopeName - The scope identier (request, session)
java.lang.IllegalAccessException - If object cannot be created
java.lang.InstantiationException - If object cannot be created
java.lang.IllegalArgumentException - If form config is missing from module
or scopeName is invalid
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||