|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.stripes.action.ActionBeanContext
public class ActionBeanContext
Encapsulates information about the current request. Also provides access to the underlying Servlet API should you need to use it for any reason.
Developers should generally consider subclassing ActionBeanContext to provide a facade to contextual state for their application. Type safe getters and setter can be added to the subclass and used by the application, thus hiding where the information is actually stored. This approach is documented in more detail in the Stripes documentation on State Management.
Constructor Summary | |
---|---|
ActionBeanContext()
|
Method Summary | |
---|---|
String |
getEventName()
Supplies the name of the event being handled. |
Locale |
getLocale()
Gets the Locale that is being used to service the current request. |
List<Message> |
getMessages()
Returns the default set of non-error messages associated with the current request. |
List<Message> |
getMessages(String key)
Returns the set of non-error messages associated with the current request under the specified key. |
HttpServletRequest |
getRequest()
Retrieves the HttpServletRequest object that is associated with the current request. |
HttpServletResponse |
getResponse()
Retrieves the HttpServletResponse that is associated with the current request. |
ServletContext |
getServletContext()
Retrieves the ServletContext object that is associated with the context in which the current request is being processed. |
String |
getSourcePage()
Returns the context-relative path to the page from which the user submitted they current request. |
Resolution |
getSourcePageResolution()
Returns a resolution that can be used to return the user to the page from which they submitted they current request. |
ValidationErrors |
getValidationErrors()
Returns the set of validation errors associated with the current form. |
void |
setEventName(String eventName)
Used by the DispatcherServlet to set the name of the even being handled. |
void |
setRequest(HttpServletRequest request)
Used by the DispatcherServlet to set the HttpServletRequest for the current request |
void |
setResponse(HttpServletResponse response)
Used by the DispatcherServlet to set the HttpServletResponse that is associated with the current request. |
void |
setServletContext(ServletContext servletContext)
Sets the ServletContext object that is associated with the context in which the current request is being processed. |
void |
setValidationErrors(ValidationErrors validationErrors)
Replaces the current set of validation errors. |
String |
toString()
Returns a String with the name of the event for which the instance holds context, and the set of validation errors, if any. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ActionBeanContext()
Method Detail |
---|
public HttpServletRequest getRequest()
public void setRequest(HttpServletRequest request)
request
- the current requestpublic HttpServletResponse getResponse()
public void setResponse(HttpServletResponse response)
response
- the current responsepublic ServletContext getServletContext()
public void setServletContext(ServletContext servletContext)
servletContext
- the current ServletContextpublic String getEventName()
public void setEventName(String eventName)
eventName
- the name of the event being handledpublic ValidationErrors getValidationErrors()
public void setValidationErrors(ValidationErrors validationErrors)
validationErrors
- a collect of validation errorspublic List<Message> getMessages()
Returns the default set of non-error messages associated with the current request. Guaranteed to always return a List, though the list may be empty. It is envisaged that messages will normally be added to the request as follows:
getContext().getMessages().add( ... );
To remove messages from the current request fetch the list of messages and invoke remove() or clear(). Messages will be made available to JSPs during the current request and in the subsequent request if a redirect is issued.
getMessages(String)
public List<Message> getMessages(String key)
Returns the set of non-error messages associated with the current request under the specified key. Can be used to manage multiple lists of messages, for different purposes. Guaranteed to always return a List, though the list may be empty. It is envisaged that messages will normally be added to the request as follows:
getContext().getMessages(key).add( ... );
To remove messages from the current request fetch the list of messages and invoke remove() or clear().
Messages are stored in a FlashScope
for
the current request. This means that they are available in request scope using the
supplied key during both this request, and the subsequent request if it is the result
of a redirect.
public Locale getLocale()
LocalePicker
public Resolution getSourcePageResolution()
Returns a resolution that can be used to return the user to the page from which they submitted they current request. Most useful in situations where a user-correctable error has occurred that was too difficult or expensive to check at validation time. In that case an ActionBean can call setValidationErrors() and then return the resolution provided by this method.
IllegalStateException
- if the information required to construct a source page
resolution cannot be found in the request.getSourcePage()
public String getSourcePage()
Returns the context-relative path to the page from which the user submitted they current request.
IllegalStateException
- if the information required to construct a source page
resolution cannot be found in the request.getSourcePageResolution()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |