org.apache.empire.struts2.action
Class WebAction

java.lang.Object
  extended by org.apache.empire.struts2.actionsupport.ActionBase
      extended by org.apache.empire.struts2.action.WebAction
All Implemented Interfaces:
com.opensymphony.xwork2.LocaleProvider, com.opensymphony.xwork2.TextProvider, ActionAccessValidator, ActionErrorProvider, ActionItemProperty, Disposable, ExceptionAware, RequestParamProvider

public abstract class WebAction
extends ActionBase
implements Disposable, ExceptionAware, ActionAccessValidator, ActionItemProperty, RequestParamProvider, ActionErrorProvider, com.opensymphony.xwork2.TextProvider, com.opensymphony.xwork2.LocaleProvider

WebAction should be used as the superclass for all your struts2 action classes.
It implements necessary interfaces for parameter-, translation- and error-handling.


Field Summary
static java.lang.String DEFAULT_ITEM_PROPERTY_NAME
           
 
Fields inherited from interface org.apache.empire.struts2.action.Disposable
EXITCODE_ERROR, EXITCODE_SUCCESS
 
Constructor Summary
WebAction()
           
 
Method Summary
 void clearActionErrors()
          clears the action error (if any) and all item errors
 void clearItem()
           
 int dispose()
          Cleanup resources allocated by the action this requires the action to be stored on the request in a param named "action" the ActionBasicsInterceptor performs this task the dispose method will then be called from the EmpireStrutsDispatcher
 java.lang.String getActionURL(java.lang.String action, java.util.Map parameters)
           
 java.lang.String getItem()
           
 java.util.Map<java.lang.String,org.apache.empire.commons.ErrorInfo> getItemErrors()
          returns a map of field errors field errors are not persisted on the session and will be lost on redirects.
 java.lang.String getItemPropertyName()
          returns the name of the parameter used to get and set the action's item This function is used by the jsp tags as default parameter name of the item attribute By default this ist the name "item"
 org.apache.empire.commons.ErrorInfo getLastActionError(boolean clear)
          returns the last Action Error of the current or a previous aciton the error is left on the session unless the clear flag is set to true In order to display the error to the user an application should use this function instead of getActionError() and set clear to true.
 java.lang.String getLastActionMessage(boolean clear)
          returns the last set Action Message the message is left on the session unless the clear flag is set to true
 int getListPageSize()
           
 java.util.Locale getLocale()
           
 java.lang.String getLocalizedErrorMessage(org.apache.empire.commons.ErrorInfo error)
          return the localized message for an error
 java.lang.String[] getRequestArrayParam(java.lang.String param)
           
 java.lang.Integer getRequestIntParam(java.lang.String param)
           
 java.lang.String getRequestParam(java.lang.String param)
           
 java.util.Map getRequestParameters()
           
 java.lang.String getText(java.lang.String aTextName)
           
 java.lang.String getText(java.lang.String aTextName, java.util.List args)
           
 java.lang.String getText(java.lang.String aTextName, java.lang.String defaultValue)
           
 java.lang.String getText(java.lang.String key, java.lang.String[] args)
           
 java.lang.String getText(java.lang.String aTextName, java.lang.String defaultValue, java.util.List args)
           
 java.lang.String getText(java.lang.String key, java.lang.String defaultValue, java.util.List args, com.opensymphony.xwork2.util.ValueStack stack)
           
 java.lang.String getText(java.lang.String aTextName, java.lang.String defaultValue, java.lang.String obj)
           
 java.lang.String getText(java.lang.String key, java.lang.String defaultValue, java.lang.String[] args)
           
 java.lang.String getText(java.lang.String key, java.lang.String defaultValue, java.lang.String[] args, com.opensymphony.xwork2.util.ValueStack stack)
           
 java.util.ResourceBundle getTexts()
           
 java.util.ResourceBundle getTexts(java.lang.String aBundleName)
           
 java.lang.String handleException(java.lang.Throwable exception, java.lang.String method)
          handle any exception that may have occurred The method is called from the ActionBasicsInterceptor
 boolean hasAccess(java.lang.String method)
          Determines whether the user has access to this page or a particular method The method is called from the ActionAccessInterceptor
 boolean hasActionError()
          returns true if the current action has either an action or a field error WARNING: this function returns false if a previous action had an error
 boolean hasRequestParam(java.lang.String param)
           
 void init()
          Initialize the action Should be used instead of the constructor to initialize the action The method is called from the ActionBasicsInterceptor
 boolean isNewItem()
           
 boolean loginRequired()
          Determines whether the user needs to Login to access this page important: return false if the user has already logged in!
 void putRequestParam(java.lang.String name, java.lang.String value)
           
 void setItem(java.lang.String value)
           
 
Methods inherited from class org.apache.empire.struts2.actionsupport.ActionBase
getActionBean, getActionBean, getRecordKeyString, getRecordKeyString, putActionBean, putActionBean, removeActionBean, removeActionBean
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ITEM_PROPERTY_NAME

public static java.lang.String DEFAULT_ITEM_PROPERTY_NAME
Constructor Detail

WebAction

public WebAction()
Method Detail

init

public void init()
Initialize the action Should be used instead of the constructor to initialize the action The method is called from the ActionBasicsInterceptor

Specified by:
init in interface Disposable

dispose

public int dispose()
Cleanup resources allocated by the action this requires the action to be stored on the request in a param named "action" the ActionBasicsInterceptor performs this task the dispose method will then be called from the EmpireStrutsDispatcher

Specified by:
dispose in interface Disposable
Returns:
an exit code which will be passed to the WebRequest's exit function (@see WebRequest.exit())

handleException

public java.lang.String handleException(java.lang.Throwable exception,
                                        java.lang.String method)
handle any exception that may have occurred The method is called from the ActionBasicsInterceptor

Specified by:
handleException in interface ExceptionAware
Parameters:
exception - the exception that occurred
Returns:
the target mapping which to execute

loginRequired

public boolean loginRequired()
Determines whether the user needs to Login to access this page important: return false if the user has already logged in! The method is called from the ActionAccessInterceptor

Specified by:
loginRequired in interface ActionAccessValidator

hasAccess

public boolean hasAccess(java.lang.String method)
Determines whether the user has access to this page or a particular method The method is called from the ActionAccessInterceptor

Specified by:
hasAccess in interface ActionAccessValidator

hasActionError

public boolean hasActionError()
Description copied from interface: ActionErrorProvider
returns true if the current action has either an action or a field error WARNING: this function returns false if a previous action had an error

Specified by:
hasActionError in interface ActionErrorProvider
Returns:
true if either an Action Error or a Field Error has been set

clearActionErrors

public void clearActionErrors()
Description copied from interface: ActionErrorProvider
clears the action error (if any) and all item errors

Specified by:
clearActionErrors in interface ActionErrorProvider

getLastActionError

public org.apache.empire.commons.ErrorInfo getLastActionError(boolean clear)
Description copied from interface: ActionErrorProvider
returns the last Action Error of the current or a previous aciton the error is left on the session unless the clear flag is set to true In order to display the error to the user an application should use this function instead of getActionError() and set clear to true.

Specified by:
getLastActionError in interface ActionErrorProvider
Parameters:
clear - flag that determines whether to remove this error from the session or not
Returns:
the last Action error that has been put on the session

getLocalizedErrorMessage

public java.lang.String getLocalizedErrorMessage(org.apache.empire.commons.ErrorInfo error)
Description copied from interface: ActionErrorProvider
return the localized message for an error

Specified by:
getLocalizedErrorMessage in interface ActionErrorProvider
Returns:
the error message in the curren user's language

getItemErrors

public java.util.Map<java.lang.String,org.apache.empire.commons.ErrorInfo> getItemErrors()
Description copied from interface: ActionErrorProvider
returns a map of field errors field errors are not persisted on the session and will be lost on redirects.

Specified by:
getItemErrors in interface ActionErrorProvider
Returns:
the map of field errors containing the field name in the key.

getLastActionMessage

public java.lang.String getLastActionMessage(boolean clear)
Description copied from interface: ActionErrorProvider
returns the last set Action Message the message is left on the session unless the clear flag is set to true

Specified by:
getLastActionMessage in interface ActionErrorProvider
Returns:
an action message for the user

getLocale

public java.util.Locale getLocale()
Specified by:
getLocale in interface com.opensymphony.xwork2.LocaleProvider

getText

public java.lang.String getText(java.lang.String aTextName)
Specified by:
getText in interface com.opensymphony.xwork2.TextProvider

getText

public java.lang.String getText(java.lang.String aTextName,
                                java.lang.String defaultValue)
Specified by:
getText in interface com.opensymphony.xwork2.TextProvider

getText

public java.lang.String getText(java.lang.String aTextName,
                                java.lang.String defaultValue,
                                java.lang.String obj)
Specified by:
getText in interface com.opensymphony.xwork2.TextProvider

getText

public java.lang.String getText(java.lang.String aTextName,
                                java.util.List args)
Specified by:
getText in interface com.opensymphony.xwork2.TextProvider

getText

public java.lang.String getText(java.lang.String key,
                                java.lang.String[] args)
Specified by:
getText in interface com.opensymphony.xwork2.TextProvider

getText

public java.lang.String getText(java.lang.String aTextName,
                                java.lang.String defaultValue,
                                java.util.List args)
Specified by:
getText in interface com.opensymphony.xwork2.TextProvider

getText

public java.lang.String getText(java.lang.String key,
                                java.lang.String defaultValue,
                                java.lang.String[] args)
Specified by:
getText in interface com.opensymphony.xwork2.TextProvider

getText

public java.lang.String getText(java.lang.String key,
                                java.lang.String defaultValue,
                                java.util.List args,
                                com.opensymphony.xwork2.util.ValueStack stack)
Specified by:
getText in interface com.opensymphony.xwork2.TextProvider

getText

public java.lang.String getText(java.lang.String key,
                                java.lang.String defaultValue,
                                java.lang.String[] args,
                                com.opensymphony.xwork2.util.ValueStack stack)
Specified by:
getText in interface com.opensymphony.xwork2.TextProvider

getTexts

public java.util.ResourceBundle getTexts()
Specified by:
getTexts in interface com.opensymphony.xwork2.TextProvider

getTexts

public java.util.ResourceBundle getTexts(java.lang.String aBundleName)
Specified by:
getTexts in interface com.opensymphony.xwork2.TextProvider

getListPageSize

public int getListPageSize()
Specified by:
getListPageSize in class ActionBase

getItemPropertyName

public java.lang.String getItemPropertyName()
Description copied from interface: ActionItemProperty
returns the name of the parameter used to get and set the action's item This function is used by the jsp tags as default parameter name of the item attribute By default this ist the name "item"

Specified by:
getItemPropertyName in interface ActionItemProperty
Returns:
the name of the item parameter

getItem

public java.lang.String getItem()

setItem

public void setItem(java.lang.String value)

clearItem

public void clearItem()

isNewItem

public boolean isNewItem()

getRequestParameters

public final java.util.Map getRequestParameters()
Specified by:
getRequestParameters in interface RequestParamProvider

hasRequestParam

public final boolean hasRequestParam(java.lang.String param)
Specified by:
hasRequestParam in interface RequestParamProvider

getRequestParam

public final java.lang.String getRequestParam(java.lang.String param)
Specified by:
getRequestParam in interface RequestParamProvider

getRequestArrayParam

public final java.lang.String[] getRequestArrayParam(java.lang.String param)
Specified by:
getRequestArrayParam in interface RequestParamProvider

getRequestIntParam

public final java.lang.Integer getRequestIntParam(java.lang.String param)

putRequestParam

public final void putRequestParam(java.lang.String name,
                                  java.lang.String value)

getActionURL

public java.lang.String getActionURL(java.lang.String action,
                                     java.util.Map parameters)