public class ServletActionContext extends WebActionContext
Implement ActionContext interface while making Servlet API-specific values available.
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_KEYAPPLICATION_SCOPE, REQUEST_SCOPE, SESSION_SCOPE| Constructor and Description |
|---|
ServletActionContext(javax.servlet.ServletContext context,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Instantiate this Context for a given ServletContext,
HttpServletRequest, and HttpServletResponse.
|
ServletActionContext(org.apache.commons.chain.web.servlet.ServletWebContext context)
Instantiate this composite by wrapping a ServletWebContext.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
String |
generateToken()
Generate a new transaction token, to be used for enforcing a single
request for a particular transaction.
|
ActionServlet |
getActionServlet()
Return the ActionServlet for this context.
|
javax.servlet.ServletContext |
getContext()
Return the ServletContext for this context.
|
ActionMessages |
getErrors()
Retrieve error messages from an internal cache, creating an empty
cache if one is not already present.
|
MessageResources |
getMessageResources()
Return the default message resources for the current module.
|
MessageResources |
getMessageResources(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.
|
javax.servlet.http.HttpServletRequest |
getRequest()
Return the HttpServletRequest for this context.
|
javax.servlet.http.HttpServletResponse |
getResponse()
Return the HttpServletResponse 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 |
resetToken()
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 |
saveToken()
Save a new transaction token in the "session" scope for this
context, creating new resources, if needed.
|
protected org.apache.commons.chain.web.servlet.ServletWebContext |
servletWebContext()
Provide the ServletWebContext for this composite.
|
void |
setActionConfig(ActionConfig actionConfig)
Set the ActionConfig class contains the details for processing this
request.
|
void |
setActionServlet(ActionServlet servlet)
Set the ActionServlet instance for this context.
|
void |
setMessageResources(MessageResources resources)
Set the default message resources for the current module.
|
void |
setMessageResources(String key,
MessageResources resources)
Store the mesasage resources for the current module under the given
request attribute key.
|
getApplicationScope, getCancelled, getHeader, getHeaderValues, getInitParam, getModuleConfig, getParam, getParameterMap, getParamValues, getRequestScope, getSessionScope, setCancelled, setModuleConfig, webContextaddActionMessages, findOrCreateActionForm, findOrCreateActionForm, getAction, getActionConfig, getActionForm, getException, getFormValid, getForwardConfig, getInclude, getLocale, getLogger, getScope, getTokenGeneratorId, isTokenValid, saveActionMessages, saveActionMessages, saveMessages, setAction, setActionForm, setException, setFormValid, setForwardConfig, setInclude, setLocale, setLoggerclear, containsKey, containsValue, entrySet, get, getBaseContext, isEmpty, keySet, put, putAll, remove, size, valuesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuespublic ServletActionContext(org.apache.commons.chain.web.servlet.ServletWebContext context)
Instantiate this composite by wrapping a ServletWebContext.
context - The ServletWebContext to wrappublic ServletActionContext(javax.servlet.ServletContext context,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Instantiate this Context for a given ServletContext, HttpServletRequest, and HttpServletResponse.
context - The instant ServletContextrequest - The instant HttpServletRequestresponse - The instant HttpServletResponseprotected org.apache.commons.chain.web.servlet.ServletWebContext servletWebContext()
Provide the ServletWebContext for this composite.
public void release()
ActionContextrelease in interface ActionContextrelease in class WebActionContextpublic javax.servlet.ServletContext getContext()
Return the ServletContext for this context.
public javax.servlet.http.HttpServletRequest getRequest()
Return the HttpServletRequest for this context.
public javax.servlet.http.HttpServletResponse getResponse()
Return the HttpServletResponse for this context.
public ActionServlet getActionServlet()
Return the ActionServlet for this context.
public void setActionServlet(ActionServlet servlet)
Set the ActionServlet instance for this context.
servlet - Our ActionServlet instancepublic void setActionConfig(ActionConfig actionConfig)
ActionContextSet the ActionConfig class contains the details for processing this request.
setActionConfig in interface ActionContextsetActionConfig in class ActionContextBaseactionConfig - The ActionConfig class to use with this requestpublic MessageResources getMessageResources()
ActionContextReturn the default message resources for the current module.
getMessageResources in interface ActionContextgetMessageResources in class ActionContextBasepublic MessageResources getMessageResources(String key)
ActionContextReturn the specified message resources for the current module.
getMessageResources in interface ActionContextgetMessageResources in class ActionContextBasekey - The key specified in the <message-resources>
element for the requested bundlepublic void setMessageResources(MessageResources resources)
ActionContextSet the default message resources for the current module.
setMessageResources in interface ActionContextsetMessageResources in class ActionContextBasepublic void setMessageResources(String key, MessageResources resources)
Store the mesasage resources for the current module under the given request attribute key.
key - Request attribute keyresources - Message resouces to storepublic 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 ActionContextsaveErrors in class ActionContextBaseerrors - 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 ActionContextsaveMessages in class ActionContextBasemessages - ActionMesssages to cachepublic 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 ActionContextaddMessages in class ActionContextBasemessages - 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 ActionContextaddErrors in class ActionContextBaseerrors - 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 ActionContextgetErrors in class ActionContextBasepublic ActionMessages getMessages()
ActionContextRetrieve messages from an internal cache, creating an empty cache if one is not already present.
getMessages in interface ActionContextgetMessages in class ActionContextBasepublic void saveToken()
ActionContextSave a new transaction token in the "session" scope for this context, creating new resources, if needed.
saveToken in interface ActionContextsaveToken in class ActionContextBasepublic String generateToken()
ActionContextGenerate a new transaction token, to be used for enforcing a single request for a particular transaction.
generateToken in interface ActionContextgenerateToken in class ActionContextBasepublic 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 ActionContextisTokenValid in class ActionContextBasereset - 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 ActionContextresetToken in class ActionContextBaseCopyright © 2000-2017 Apache Software Foundation. All Rights Reserved.