Class ServletActionContext
- All Implemented Interfaces:
Map<String,
,Object> org.apache.commons.chain.Context
,ActionContext
-
Nested Class Summary
-
Field Summary
Fields inherited from class org.apache.struts.chain.contexts.ActionContextBase
ACTION_CONFIG_KEY, ACTION_FORM_KEY, ACTION_KEY, CANCEL_KEY, ERROR_ACTION_MESSAGES_KEY, EXCEPTION_KEY, FORWARD_CONFIG_KEY, INCLUDE_KEY, LOCALE_KEY, MESSAGE_ACTION_MESSAGES_KEY, MESSAGE_RESOURCES_KEY, MODULE_CONFIG_KEY, token, TOKEN_KEY, TRANSACTION_TOKEN_KEY, VALID_KEY
Fields inherited from interface org.apache.struts.chain.contexts.ActionContext
APPLICATION_SCOPE, REQUEST_SCOPE, SESSION_SCOPE
-
Constructor Summary
ConstructorDescriptionServletActionContext
(ServletContext context, HttpServletRequest request, HttpServletResponse response) Instantiate this Context for a givenServletContext
,HttpServletRequest
, andHttpServletResponse
.ServletActionContext
(org.apache.commons.chain.web.jakarta.servlet.ServletWebContext context) Instantiate this composite by wrapping a ServletWebContext. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.Generate a new transaction token, to be used for enforcing a single request for a particular transaction.Return theActionServlet
for this context.Return theServletContext
for this context.Retrieve error messages from an internal cache, creating an empty cache if one is not already present.Return the default message resources for the current module.Return the specified message resources for the current module.Retrieve messages from an internal cache, creating an empty cache if one is not already present.Return theHttpServletRequest
for this context.Return theHttpServletResponse
for this context.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
Clear any transactional token stored in the "session" scope for this context, so that the next check would return false.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
Save a new transaction token in the "session" scope for this context, creating new resources, if needed.protected org.apache.commons.chain.web.jakarta.servlet.ServletWebContext
Provide theServletWebContext
for this composite.void
setActionConfig
(ActionConfig actionConfig) Set the ActionConfig class contains the details for processing this request.void
setActionServlet
(ActionServlet servlet) Set theActionServlet
instance for this context.void
setMessageResources
(String key, MessageResources resources) Store the message resources for the current module under the given request attribute key.void
setMessageResources
(MessageResources resources) Set the default message resources for the current module.Methods inherited from class org.apache.struts.chain.contexts.WebActionContext
getApplicationScope, getCancelled, getHeader, getHeaderValues, getInitParam, getModuleConfig, getParam, getParameterMap, getParamValues, getRequestScope, getSessionScope, setCancelled, setModuleConfig, webContext
Methods inherited from class org.apache.struts.chain.contexts.ActionContextBase
addActionMessages, findOrCreateActionForm, findOrCreateActionForm, getAction, getActionConfig, getActionForm, getException, getFormValid, getForwardConfig, getInclude, getLocale, getLogger, getScope, getTokenGeneratorId, isTokenValid, saveActionMessages, saveActionMessages, saveMessages, setAction, setActionForm, setException, setFormValid, setForwardConfig, setInclude, setLocale, setLogger
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 java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Constructor Details
-
ServletActionContext
public ServletActionContext(org.apache.commons.chain.web.jakarta.servlet.ServletWebContext context) Instantiate this composite by wrapping a ServletWebContext.- Parameters:
context
- The ServletWebContext to wrap
-
ServletActionContext
public ServletActionContext(ServletContext context, HttpServletRequest request, HttpServletResponse response) Instantiate this Context for a givenServletContext
,HttpServletRequest
, andHttpServletResponse
.- Parameters:
context
- The instant ServletContextrequest
- The instant HttpServletRequestresponse
- The instant HttpServletResponse
-
-
Method Details
-
servletWebContext
protected org.apache.commons.chain.web.jakarta.servlet.ServletWebContext servletWebContext()Provide theServletWebContext
for this composite.- Returns:
- Our ServletWebContext
-
release
public void release()Description copied from interface:ActionContext
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.- Specified by:
release
in interfaceActionContext
- Overrides:
release
in classWebActionContext
-
getContext
Return theServletContext
for this context.- Returns:
- Our ServletContext
-
getRequest
Return theHttpServletRequest
for this context.- Returns:
- Our HttpServletRequest
-
getResponse
Return theHttpServletResponse
for this context.- Returns:
- Our HttpServletResponse
-
getActionServlet
Return theActionServlet
for this context.- Returns:
- Our ActionServlet
-
setActionServlet
Set theActionServlet
instance for this context.- Parameters:
servlet
- Our ActionServlet instance
-
setActionConfig
Description copied from interface:ActionContext
Set the ActionConfig class contains the details for processing this request.
- Specified by:
setActionConfig
in interfaceActionContext
- Overrides:
setActionConfig
in classActionContextBase
- Parameters:
actionConfig
- The ActionConfig class to use with this request
-
getMessageResources
Description copied from interface:ActionContext
Return the default message resources for the current module.
- Specified by:
getMessageResources
in interfaceActionContext
- Overrides:
getMessageResources
in classActionContextBase
-
getMessageResources
Description copied from interface:ActionContext
Return the specified message resources for the current module.
- Specified by:
getMessageResources
in interfaceActionContext
- Overrides:
getMessageResources
in classActionContextBase
- Parameters:
key
- The key specified in the<message-resources>
element for the requested bundle
-
setMessageResources
Description copied from interface:ActionContext
Set the default message resources for the current module.
- Specified by:
setMessageResources
in interfaceActionContext
- Overrides:
setMessageResources
in classActionContextBase
-
setMessageResources
Store the message resources for the current module under the given request attribute key.- Parameters:
key
- Request attribute keyresources
- Message resources to store
-
saveErrors
Description copied from interface: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.
- Specified by:
saveErrors
in interfaceActionContext
- Overrides:
saveErrors
in classActionContextBase
- Parameters:
errors
- ActionMesssages to cache as errors
-
saveMessages
Description copied from interface: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.
- Specified by:
saveMessages
in interfaceActionContext
- Overrides:
saveMessages
in classActionContextBase
- Parameters:
messages
- ActionMesssages to cache
-
addMessages
Description copied from interface:ActionContext
Append the given messages keys to an internal cache, creating the cache if one is not already present.
- Specified by:
addMessages
in interfaceActionContext
- Overrides:
addMessages
in classActionContextBase
- Parameters:
messages
- New ActionMessages to cache
-
addErrors
Description copied from interface:ActionContext
Append the given errors keys to an internal cache, creating the cache if one is not already present.
- Specified by:
addErrors
in interfaceActionContext
- Overrides:
addErrors
in classActionContextBase
- Parameters:
errors
- New ActionMessages to cache as errors
-
getErrors
Description copied from interface:ActionContext
Retrieve error messages from an internal cache, creating an empty cache if one is not already present.
- Specified by:
getErrors
in interfaceActionContext
- Overrides:
getErrors
in classActionContextBase
- Returns:
- The ActionMessage cache for errors
-
getMessages
Description copied from interface:ActionContext
Retrieve messages from an internal cache, creating an empty cache if one is not already present.
- Specified by:
getMessages
in interfaceActionContext
- Overrides:
getMessages
in classActionContextBase
- Returns:
- The ActionMessage cache for errors
-
saveToken
public void saveToken()Description copied from interface:ActionContext
Save a new transaction token in the "session" scope for this context, creating new resources, if needed.
- Specified by:
saveToken
in interfaceActionContext
- Overrides:
saveToken
in classActionContextBase
-
generateToken
Description copied from interface:ActionContext
Generate a new transaction token, to be used for enforcing a single request for a particular transaction.
- Specified by:
generateToken
in interfaceActionContext
- Overrides:
generateToken
in classActionContextBase
-
isTokenValid
public boolean isTokenValid(boolean reset) Description copied from interface: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.
- Specified by:
isTokenValid
in interfaceActionContext
- Overrides:
isTokenValid
in classActionContextBase
- Parameters:
reset
- On true, clear the transactional token
-
resetToken
public void resetToken()Description copied from interface:ActionContext
Clear any transactional token stored in the "session" scope for this context, so that the next check would return false.
- Specified by:
resetToken
in interfaceActionContext
- Overrides:
resetToken
in classActionContextBase
-