org.loom.action
Class AbstractAction

java.lang.Object
  extended by org.loom.action.AbstractAction
All Implemented Interfaces:
Action
Direct Known Subclasses:
AbstractActionImpl, ResourcesAction

public abstract class AbstractAction
extends java.lang.Object
implements Action

Abstract superclass that provides some methods for the most common use.


Constructor Summary
AbstractAction()
           
 
Method Summary
 Message addError(Message message)
          Deprecated. use addMessage() instead
 Message addError(java.lang.String messageKey)
          Deprecated. use error() instead
 Message addError(java.lang.String normalizedPropertyPath, java.lang.String messageKey)
          Deprecated. use error() instead
 Message addMessage(Message message)
           
protected  Message error(java.lang.String messageKey)
           
protected  Message error(java.lang.String propertyPath, java.lang.String messageKey)
           
protected  ForwardResolution forward()
          Forwards to a page name with the same name of the current event
protected  ForwardResolution forward(java.lang.String pageName)
          Forwards to the provided JSP page name.
protected  ForwardResolution forwardWithLocale(java.lang.String pageName)
          Forward to a page, with preference for a localized page if possible.
 ActionContext getContext()
           
 MessagesRepository getMessagesRepository()
           
protected  java.lang.String getParam(java.lang.String propertyPath)
          Deprecated. use getPropertyAsString instead
protected  java.lang.String getPropertyAsString(java.lang.String propertyPath)
          Returns the value of the given property as a UrlParameter to be added to a Resolution
 LoomServletRequest getRequest()
           
 LoomServletResponse getResponse()
           
 javax.servlet.http.HttpSession getSession()
           
 javax.servlet.http.HttpSession getSession(boolean create)
           
 boolean hasAnyError()
           
 boolean hasAnyError(java.lang.String propertyPath)
           
protected  Message info(java.lang.String messageKey)
           
protected  JacksonResolution json(java.lang.Object contents)
           
protected  RedirectResolution redirect(java.lang.Class<? extends Action> actionClass)
          Redirects to the provided action, default event
protected  RedirectResolution redirect(java.lang.Class<? extends Action> actionClass, java.lang.String event)
          Redirects to the provided action and event.
protected  RedirectResolution redirect(java.lang.String uri)
          Redirects to the provided url
protected  RedirectResolution redirect(java.lang.String action, java.lang.String event)
          Redirects to the provided action and event.
protected  PersistentFileResolution send(PersistentFile file)
          Send a file to the browser.
protected  StringResolution send(java.lang.String results)
          Return a simple text as the response.
protected  InputStreamResolution send(java.lang.String filename, java.io.InputStream input)
          Send a file to the browser.
 void setContext(ActionContext context)
           
protected  Message warn(java.lang.String messageKey)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractAction

public AbstractAction()
Method Detail

setContext

public void setContext(ActionContext context)
Specified by:
setContext in interface Action

getMessagesRepository

public MessagesRepository getMessagesRepository()

hasAnyError

public boolean hasAnyError()
Returns:
true if there is any validation/conversion error

hasAnyError

public boolean hasAnyError(java.lang.String propertyPath)
Parameters:
propertyPath - the property path to search error for
Returns:
true if there are validation/conversion errors associated to the provided property path

forward

protected ForwardResolution forward(java.lang.String pageName)
Forwards to the provided JSP page name.


forwardWithLocale

protected ForwardResolution forwardWithLocale(java.lang.String pageName)
Forward to a page, with preference for a localized page if possible. A forward to "myfile.jsp" with spanish request locale and english default locale will first try "myfile_es.jsp", then "myfile_en.jsp" and, if none is found, "myfile.jsp"

Parameters:
pageName - the name of the resource to forward to
Returns:
a ForwardResolution to the provided page
See Also:
LocaleForwardResolution

forward

protected ForwardResolution forward()
Forwards to a page name with the same name of the current event


redirect

protected RedirectResolution redirect(java.lang.String uri)
Redirects to the provided url


redirect

protected RedirectResolution redirect(java.lang.Class<? extends Action> actionClass,
                                      java.lang.String event)
Redirects to the provided action and event.


redirect

protected RedirectResolution redirect(java.lang.Class<? extends Action> actionClass)
Redirects to the provided action, default event


redirect

protected RedirectResolution redirect(java.lang.String action,
                                      java.lang.String event)
Redirects to the provided action and event. The action parameter can be the short or full action name


send

protected PersistentFileResolution send(PersistentFile file)
Send a file to the browser.


send

protected InputStreamResolution send(java.lang.String filename,
                                     java.io.InputStream input)
Send a file to the browser.


send

protected StringResolution send(java.lang.String results)
Return a simple text as the response. The mime type will be set as text/plain by default.

Parameters:
results - the result to be handled to the browser as is.

getPropertyAsString

protected java.lang.String getPropertyAsString(java.lang.String propertyPath)
Returns the value of the given property as a UrlParameter to be added to a Resolution


getParam

protected java.lang.String getParam(java.lang.String propertyPath)
Deprecated. use getPropertyAsString instead


getContext

public ActionContext getContext()
Specified by:
getContext in interface Action

getRequest

public LoomServletRequest getRequest()
Returns:
the request object that is being processed

getResponse

public LoomServletResponse getResponse()
Returns:
the response object that will be returned

getSession

public javax.servlet.http.HttpSession getSession()

getSession

public javax.servlet.http.HttpSession getSession(boolean create)

addError

public Message addError(java.lang.String normalizedPropertyPath,
                        java.lang.String messageKey)
Deprecated. use error() instead


addError

public Message addError(java.lang.String messageKey)
Deprecated. use error() instead


addError

public Message addError(Message message)
Deprecated. use addMessage() instead


addMessage

public Message addMessage(Message message)

error

protected Message error(java.lang.String propertyPath,
                        java.lang.String messageKey)

error

protected Message error(java.lang.String messageKey)

info

protected Message info(java.lang.String messageKey)

warn

protected Message warn(java.lang.String messageKey)

json

protected JacksonResolution json(java.lang.Object contents)