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 String DEFAULT_ITEM_PROPERTY_NAME
           
protected static org.slf4j.Logger log
           
static 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(String name, Column column, ErrorInfo error)
           
protected  void addItemError(String item, ErrorType errorType, 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  String getActionParam(String name)
           
 String getActionURL(String action, Map<String,Object> parameters)
          Deprecated.  
protected  Connection getConnection()
           
 String getItem()
           
 Map<String,ErrorInfo> getItemErrors()
          returns a map of field errors field errors are not persisted on the session and will be lost on redirects.
protected  Object[] getItemKey()
           
protected  boolean getItemNewFlag()
           
 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 action 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.
 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()
           
 Locale getLocale()
           
 String getLocalizedErrorMessage(ErrorInfo error)
          return the localized message for an error
 String[] getRequestArrayParam(String param)
           
 Integer getRequestIntParam(String param)
           
 String getRequestParam(String param)
           
 Map<String,Object> getRequestParameters()
           
 String getText(String aTextName)
           
 String getText(String aTextName, List<Object> args)
           
 String getText(String aTextName, String defaultValue)
           
 String getText(String key, String[] args)
           
 String getText(String aTextName, String defaultValue, List<Object> args)
           
 String getText(String key, String defaultValue, List<Object> args, com.opensymphony.xwork2.util.ValueStack stack)
           
 String getText(String aTextName, String defaultValue, String obj)
           
 String getText(String key, String defaultValue, String[] args)
           
 String getText(String key, String defaultValue, String[] args, com.opensymphony.xwork2.util.ValueStack stack)
           
 ResourceBundle getTexts()
           
 ResourceBundle getTexts(String aBundleName)
           
 String handleException(Throwable exception, String method)
          handle any exception that may have occurred The method is called from the ActionBasicsInterceptor
 boolean hasAccess(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(String key)
           
 boolean hasRequestParam(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(String name, String value)
           
 String renderPortlet()
           
protected  void setActionError(ErrorInfo error)
           
protected  void setActionError(ErrorType errType)
           
protected  void setActionError(ErrorType errType, String param)
           
 void setActionError(Exception exception)
           
protected  void setActionMessage(String message)
           
 void setItem(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.slf4j.Logger log

DEFAULT_ITEM_PROPERTY_NAME

public static String DEFAULT_ITEM_PROPERTY_NAME

PORTLET_ACTION_RESULT

public static 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 String handleException(Throwable exception,
                              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(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 action 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 String getLocalizedErrorMessage(ErrorInfo error)
Description copied from interface: ActionErrorProvider
return the localized message for an error

Specified by:
getLocalizedErrorMessage in interface ActionErrorProvider
Parameters:
error - the error info
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,
                                    String param)

setActionError

public final void setActionError(Exception exception)
Specified by:
setActionError in class ActionBase

getItemErrors

public Map<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(String item,
                            ErrorType errorType,
                            String title,
                            ErrorInfo error)

addFieldError

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

getLastActionMessage

public 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
Parameters:
clear - if true will clear the message from the session
Returns:
an action message for the user

setActionMessage

protected void setActionMessage(String message)

getLocale

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

hasKey

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

getText

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

getText

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

getText

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

getText

public String getText(String aTextName,
                      List<Object> args)
Specified by:
getText in interface com.opensymphony.xwork2.TextProvider

getText

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

getText

public String getText(String aTextName,
                      String defaultValue,
                      List<Object> args)
Specified by:
getText in interface com.opensymphony.xwork2.TextProvider

getText

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

getText

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

getText

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

getTexts

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

getTexts

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

getListPageSize

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

getConnection

protected Connection getConnection()
Specified by:
getConnection in class ActionBase

getItemPropertyName

public 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 String getItem()

setItem

public void setItem(String value)

clearItem

public void clearItem()

isNewItem

public boolean isNewItem()

hasItem

protected final boolean hasItem(boolean lookOnSession)

getItemKey

protected final Object[] getItemKey()

getItemNewFlag

protected final boolean getItemNewFlag()

getRequestParameters

public final Map<String,Object> getRequestParameters()
Specified by:
getRequestParameters in interface RequestParamProvider

hasRequestParam

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

getRequestParam

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

getRequestArrayParam

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

getRequestIntParam

public final Integer getRequestIntParam(String param)

putRequestParam

public final void putRequestParam(String name,
                                  String value)

getActionParam

protected String getActionParam(String name)

getActionURL

@Deprecated
public String getActionURL(String action,
                                      Map<String,Object> parameters)
Deprecated. 

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


renderPortlet

public String renderPortlet()


Copyright © 2008–2014 Apache Software Foundation. All rights reserved.