Class ServletActionContext
- All Implemented Interfaces:
Map<String,,Object> 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_KEYFields inherited from interface org.apache.struts.chain.contexts.ActionContext
APPLICATION_SCOPE, REQUEST_SCOPE, SESSION_SCOPE -
Constructor Summary
ConstructorsConstructorDescriptionServletActionContext(ServletContext context, HttpServletRequest request, HttpServletResponse response) Instantiate this Context for a givenServletContext,HttpServletRequest, andHttpServletResponse.ServletActionContext(ServletWebContext context) Instantiate this composite by wrapping a ServletWebContext. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddErrors(ActionMessages errors) Append the given errors keys to an internal cache, creating the cache if one is not already present.voidaddMessages(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 theActionServletfor this context.Return theServletContextfor 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 theHttpServletRequestfor this context.Return theHttpServletResponsefor this context.booleanisTokenValid(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.voidrelease()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.voidClear any transactional token stored in the "session" scope for this context, so that the next check would return false.voidsaveErrors(ActionMessages errors) Save the given error messages to the internal cache, clearing any previous messages in the cache.voidsaveMessages(ActionMessages messages) Save the given messages to the internal cache, clearing any previous messages in the cache.voidSave a new transaction token in the "session" scope for this context, creating new resources, if needed.protected ServletWebContextProvide theServletWebContextfor this composite.voidsetActionConfig(ActionConfig actionConfig) Set the ActionConfig class contains the details for processing this request.voidsetActionServlet(ActionServlet servlet) Set theActionServletinstance for this context.voidsetMessageResources(String key, MessageResources resources) Store the message resources for the current module under the given request attribute key.voidsetMessageResources(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, webContextMethods 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, setLoggerMethods inherited from class org.apache.struts.chain.contexts.ContextWrapper
clear, containsKey, containsValue, entrySet, get, getBaseContext, isEmpty, keySet, put, putAll, remove, size, valuesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
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
Provide theServletWebContextfor this composite.- Returns:
- Our ServletWebContext
-
release
public void release()Description copied from interface:ActionContextSignal 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:
releasein interfaceActionContext- Overrides:
releasein classWebActionContext
-
getContext
Return theServletContextfor this context.- Returns:
- Our ServletContext
-
getRequest
Return theHttpServletRequestfor this context.- Returns:
- Our HttpServletRequest
-
getResponse
Return theHttpServletResponsefor this context.- Returns:
- Our HttpServletResponse
-
getActionServlet
Return theActionServletfor this context.- Returns:
- Our ActionServlet
-
setActionServlet
Set theActionServletinstance for this context.- Parameters:
servlet- Our ActionServlet instance
-
setActionConfig
Description copied from interface:ActionContextSet the ActionConfig class contains the details for processing this request.
- Specified by:
setActionConfigin interfaceActionContext- Overrides:
setActionConfigin classActionContextBase- Parameters:
actionConfig- The ActionConfig class to use with this request
-
getMessageResources
Description copied from interface:ActionContextReturn the default message resources for the current module.
- Specified by:
getMessageResourcesin interfaceActionContext- Overrides:
getMessageResourcesin classActionContextBase
-
getMessageResources
Description copied from interface:ActionContextReturn the specified message resources for the current module.
- Specified by:
getMessageResourcesin interfaceActionContext- Overrides:
getMessageResourcesin classActionContextBase- Parameters:
key- The key specified in the<message-resources>element for the requested bundle
-
setMessageResources
Description copied from interface:ActionContextSet the default message resources for the current module.
- Specified by:
setMessageResourcesin interfaceActionContext- Overrides:
setMessageResourcesin 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: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.
- Specified by:
saveErrorsin interfaceActionContext- Overrides:
saveErrorsin classActionContextBase- Parameters:
errors- ActionMesssages to cache as errors
-
saveMessages
Description copied from interface: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.
- Specified by:
saveMessagesin interfaceActionContext- Overrides:
saveMessagesin classActionContextBase- Parameters:
messages- ActionMesssages to cache
-
addMessages
Description copied from interface:ActionContextAppend the given messages keys to an internal cache, creating the cache if one is not already present.
- Specified by:
addMessagesin interfaceActionContext- Overrides:
addMessagesin classActionContextBase- Parameters:
messages- New ActionMessages to cache
-
addErrors
Description copied from interface:ActionContextAppend the given errors keys to an internal cache, creating the cache if one is not already present.
- Specified by:
addErrorsin interfaceActionContext- Overrides:
addErrorsin classActionContextBase- Parameters:
errors- New ActionMessages to cache as errors
-
getErrors
Description copied from interface:ActionContextRetrieve error messages from an internal cache, creating an empty cache if one is not already present.
- Specified by:
getErrorsin interfaceActionContext- Overrides:
getErrorsin classActionContextBase- Returns:
- The ActionMessage cache for errors
-
getMessages
Description copied from interface:ActionContextRetrieve messages from an internal cache, creating an empty cache if one is not already present.
- Specified by:
getMessagesin interfaceActionContext- Overrides:
getMessagesin classActionContextBase- Returns:
- The ActionMessage cache for errors
-
saveToken
public void saveToken()Description copied from interface:ActionContextSave a new transaction token in the "session" scope for this context, creating new resources, if needed.
- Specified by:
saveTokenin interfaceActionContext- Overrides:
saveTokenin classActionContextBase
-
generateToken
Description copied from interface:ActionContextGenerate a new transaction token, to be used for enforcing a single request for a particular transaction.
- Specified by:
generateTokenin interfaceActionContext- Overrides:
generateTokenin classActionContextBase
-
isTokenValid
public boolean isTokenValid(boolean reset) Description copied from interface: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.
- Specified by:
isTokenValidin interfaceActionContext- Overrides:
isTokenValidin classActionContextBase- Parameters:
reset- On true, clear the transactional token
-
resetToken
public void resetToken()Description copied from interface:ActionContextClear any transactional token stored in the "session" scope for this context, so that the next check would return false.
- Specified by:
resetTokenin interfaceActionContext- Overrides:
resetTokenin classActionContextBase
-