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, ActionErrorProvider, com.opensymphony.xwork2.TextProvider

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
           
protected static org.apache.commons.logging.Log log
           
static java.lang.String PORTLET_ACTION_RESULT
           
 
Fields inherited from interface org.apache.empire.struts2.action.Disposable
EXITCODE_ERROR, EXITCODE_SUCCESS
 
Constructor Summary
WebAction()
           
 
Method Summary
protected  void addFieldError(java.lang.String name, Column column, ErrorInfo error)
           
protected  void addItemError(java.lang.String item, ErrorType errorType, java.lang.String title, ErrorInfo error)
           
 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
protected  java.lang.String getActionParam(java.lang.String name)
           
 java.lang.String getActionURL(java.lang.String action, java.util.Map parameters)
          Deprecated.  
protected  java.sql.Connection getConnection()
           
 java.lang.String getItem()
           
 java.util.Map<java.lang.String,ErrorInfo> getItemErrors()
          returns a map of field errors field errors are not persisted on the session and will be lost on redirects.
protected  java.lang.Object[] getItemKey()
           
protected  boolean getItemNewFlag()
           
 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"
 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(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<java.lang.Object> 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<java.lang.Object> args)
           
 java.lang.String getText(java.lang.String key, java.lang.String defaultValue, java.util.List<java.lang.Object> 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
protected  boolean hasItem(boolean lookOnSession)
           
 boolean hasKey(java.lang.String key)
           
 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! The method is called from the ActionAccessInterceptor
 void putRequestParam(java.lang.String name, java.lang.String value)
           
 java.lang.String renderPortlet()
           
protected  void setActionError(ErrorInfo error)
           
protected  void setActionError(ErrorType errType)
           
protected  void setActionError(ErrorType errType, java.lang.Object param)
           
protected  void setActionError(java.lang.Exception exception)
           
protected  void setActionMessage(java.lang.String message)
           
 void setItem(java.lang.String value)
           
 
Methods inherited from class org.apache.empire.struts2.actionsupport.ActionBase
getActionBean, getActionBean, getActionBeanName, getActionObject, getActionObjectName, getRecordKeyExpr, getRecordKeyFromString, getRecordKeyString, getRecordKeyString, getRecordNewFlagFromString, putActionBean, putActionBean, putActionObject, removeActionBean, removeActionBean, removeActionObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log

DEFAULT_ITEM_PROPERTY_NAME

public static java.lang.String DEFAULT_ITEM_PROPERTY_NAME

PORTLET_ACTION_RESULT

public static java.lang.String PORTLET_ACTION_RESULT
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 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(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

setActionError

protected void setActionError(ErrorInfo error)

setActionError

protected final void setActionError(ErrorType errType)

setActionError

protected final void setActionError(ErrorType errType,
                                    java.lang.Object param)

setActionError

protected final void setActionError(java.lang.Exception exception)

getItemErrors

public java.util.Map<java.lang.String,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.

addItemError

protected void addItemError(java.lang.String item,
                            ErrorType errorType,
                            java.lang.String title,
                            ErrorInfo error)

addFieldError

protected void addFieldError(java.lang.String name,
                             Column column,
                             ErrorInfo error)
Specified by:
addFieldError in class ActionBase

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

setActionMessage

protected void setActionMessage(java.lang.String message)

getLocale

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

hasKey

public boolean hasKey(java.lang.String key)
Specified by:
hasKey in interface com.opensymphony.xwork2.TextProvider

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<java.lang.Object> 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<java.lang.Object> 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<java.lang.Object> 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

getConnection

protected java.sql.Connection getConnection()
Specified by:
getConnection 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()

hasItem

protected final boolean hasItem(boolean lookOnSession)

getItemKey

protected final java.lang.Object[] getItemKey()

getItemNewFlag

protected final boolean getItemNewFlag()

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)

getActionParam

protected java.lang.String getActionParam(java.lang.String name)

getActionURL

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

returns the url for an action. Waring: The following function may only use in a Servlet environment.


renderPortlet

public java.lang.String renderPortlet()


Copyright © 2008-2010 Apache Software Foundation. All Rights Reserved.