|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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 ActionContext
public abstract java.util.Map getApplicationScope()
ActionContext
Return 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 ActionContext
public abstract java.util.Map getRequestScope()
ActionContext
Return 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 ActionContext
public abstract java.util.Map getSessionScope()
ActionContext
Return 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 ActionContext
public java.util.Map getScope(java.lang.String scopeName)
ActionContext
scopeName
. 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 ActionContext
scopeName
- A token identifying a scope, including but not limited
to APPLICATION_SCOPE
, SESSION_SCOPE
,
REQUEST_SCOPE
.
public void setAction(Action action)
ActionContext
Set the action which has been identified to be executed as part of processing this request.
setAction
in interface ActionContext
public Action getAction()
ActionContext
Get the action which has been identified to be executed as part of processing this request.
getAction
in interface ActionContext
public void setActionForm(ActionForm form)
ActionContext
Set the ActionForm instance which will carry any data submitted as part of this request.
setActionForm
in interface ActionContext
form
- The ActionForm instance to use with this requestpublic ActionForm getActionForm()
ActionContext
Get the ActionForm instance which will carry any data submitted as part of this request.
getActionForm
in interface ActionContext
public void setActionConfig(ActionConfig config)
ActionContext
Set the ActionConfig class contains the details for processing this request.
setActionConfig
in interface ActionContext
config
- The ActionConfig class to use with this requestpublic ActionConfig getActionConfig()
ActionContext
Get the ActionConfig which contains the details for processing this request.
getActionConfig
in interface ActionContext
public void setForwardConfig(ForwardConfig forward)
ActionContext
Set 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 ActionContext
forward
- The ForwardConfig to use with this requestpublic ForwardConfig getForwardConfig()
ActionContext
Get the ForwardConfig which has been identified as the basis for view-processing.
getForwardConfig
in interface ActionContext
public void setInclude(java.lang.String include)
ActionContext
Set the include path which should be processed as part of processing this request.
setInclude
in interface ActionContext
include
- The include path to be used with this requestpublic java.lang.String getInclude()
ActionContext
Get the include path which should be processed as part of processing this request.
getInclude
in interface ActionContext
public java.lang.Boolean getFormValid()
ActionContext
Is 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 ActionContext
Boolean.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)
ActionContext
Store the result of the validation of the Context's ActionForm.
setFormValid
in interface ActionContext
valid
- Whether the ActionForm for this request passes validationpublic ModuleConfig getModuleConfig()
ActionContext
Get the ModuleConfig which is operative for the current request.
getModuleConfig
in interface ActionContext
public void setModuleConfig(ModuleConfig config)
ActionContext
Set the ModuleConfig which is operative for the current request.
setModuleConfig
in interface ActionContext
config
- The ModuleConfig to be used with this requestpublic java.lang.Exception getException()
ActionContext
Retrieve an exception which may have been caught by some code using this ActionContext, usually by an exception handler.
getException
in interface ActionContext
public void setException(java.lang.Exception e)
ActionContext
Store an exception in this context for use by other handling code.
setException
in interface ActionContext
e
- An exception to be stored for handling by another memberpublic void addMessages(ActionMessages messages)
ActionContext
Append the given messages keys to an internal cache, creating the cache if one is not already present.
addMessages
in interface ActionContext
messages
- New ActionMessages to cachepublic void addErrors(ActionMessages errors)
ActionContext
Append the given errors keys to an internal cache, creating the cache if one is not already present.
addErrors
in interface ActionContext
errors
- New ActionMessages to cache as errorspublic ActionMessages getErrors()
ActionContext
Retrieve error messages from an internal cache, creating an empty cache if one is not already present.
getErrors
in interface ActionContext
public ActionMessages getMessages()
ActionContext
Retrieve messages from an internal cache, creating an empty cache if one is not already present.
getMessages
in interface ActionContext
public void saveErrors(ActionMessages errors)
ActionContext
Save 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 ActionContext
errors
- ActionMesssages to cache as errorspublic void saveMessages(ActionMessages messages)
ActionContext
Save 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 ActionContext
messages
- ActionMesssages to cachepublic 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 addpublic 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 addpublic 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 ActionContext
scope
- The scope for the internal cachemessages
- ActionMesssages to cachepublic void saveToken()
ActionContext
Save a new transaction token in the "session" scope for this context, creating new resources, if needed.
saveToken
in interface ActionContext
public java.lang.String generateToken()
ActionContext
Generate a new transaction token, to be used for enforcing a single request for a particular transaction.
generateToken
in interface ActionContext
protected java.lang.String getTokenGeneratorId()
public boolean isTokenValid()
ActionContext
Indicate 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 ActionContext
public boolean isTokenValid(boolean reset)
ActionContext
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.
isTokenValid
in interface ActionContext
reset
- On true, clear the transactional tokenpublic void resetToken()
ActionContext
Clear any transactional token stored in the "session" scope for this context, so that the next check would return false.
resetToken
in interface ActionContext
public java.lang.Boolean getCancelled()
ActionContext
Indicate if the "cancel event" state is set for for this context,
getCancelled
in interface ActionContext
ActionContextBase.CANCEL_KEY
public void setCancelled(java.lang.Boolean cancelled)
ActionContext
Set the "cancel event" state for this context.
setCancelled
in interface ActionContext
cancelled
- On true, set the cancel event state to true. On false,
set the cancel event state to false.ActionContextBase.CANCEL_KEY
public void setMessageResources(MessageResources messageResources)
ActionContext
Set the default message resources for the current module.
setMessageResources
in interface ActionContext
public MessageResources getMessageResources()
ActionContext
Return the default message resources for the current module.
getMessageResources
in interface ActionContext
public MessageResources getMessageResources(java.lang.String key)
ActionContext
Return the specified message resources for the current module.
getMessageResources
in interface ActionContext
key
- The key specified in the <message-resources>
element for the requested bundlepublic void setLocale(java.util.Locale locale)
ActionContext
Set the user's currently selected Locale
.
setLocale
in interface ActionContext
locale
- The user's selected Locale to be set, or null to select
the server's default Localepublic java.util.Locale getLocale()
ActionContext
Return the user's currently selected Locale.
getLocale
in interface ActionContext
public 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 |