com.pow2.struts.action
Class BaseAction

java.lang.Object
  extended byorg.apache.struts.action.Action
      extended bycom.pow2.struts.action.BaseAction
Direct Known Subclasses:
DispatcherAction, UserValidationAction

public class BaseAction
extends org.apache.struts.action.Action

Pow2 Struts base action.
This class adds base utility methods to other Action subclasses.
It also provides the validateSession hook method; the default implementation always returns true.
To implement your own session validation, extend this class and override the the validateSession method.
if validateSession returns false, this action forwards to the resource specified by the "invalidSession" ActionForward object.

Author:
Luca Fossato

Field Summary
protected  org.apache.log4j.Category cat
          Log4j category
protected static String FWD_CANCEL
          ActionForward cancel string
protected static String FWD_FAILURE
          ActionForward failure string
protected static String FWD_INVALID_SESSION
          ActionForward invalid session string
protected static String FWD_LOGIN
          ActionForward failure string
 
Fields inherited from class org.apache.struts.action.Action
ACTION_SERVLET_KEY, APPLICATION_KEY, DATA_SOURCE_KEY, defaultLocale, ERROR_KEY, EXCEPTION_KEY, FORM_BEANS_KEY, FORWARDS_KEY, LOCALE_KEY, MAPPING_KEY, MAPPINGS_KEY, MESSAGE_KEY, MESSAGES_KEY, MULTIPART_KEY, PLUG_INS_KEY, REQUEST_PROCESSOR_KEY, servlet, SERVLET_KEY, TRANSACTION_TOKEN_KEY
 
Constructor Summary
BaseAction()
           
 
Method Summary
protected  org.apache.struts.action.ActionForward failureForward(HttpServletRequest request, org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionErrors errors, String errorKey)
          Get the FWD_FAILURE ActionForward object, and store the error message identified by the errorKey string into the input ActionErrors object.
protected  org.apache.struts.action.ActionForward getForward(HttpServletRequest request, org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionErrors errors, String forward, String errorKey)
          Get the ActionForward object related to the input forward string, and store the error message identified by the errorKey string into the input ActionErrors object.
protected  org.apache.struts.action.ActionForward invalidSessionForward(HttpServletRequest request, org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionErrors errors)
          Get the FWD_INVALID_SESSION ActionForward object, and store the error message identified by the KEY_INVALID_SESSION key into the input ActionErrors object.
protected  boolean isFailureForward(org.apache.struts.action.ActionForward forward)
          Check if the input ActionForward object is a failure forward
protected  org.apache.struts.action.ActionForward loginForward(HttpServletRequest request, org.apache.struts.action.ActionMapping mapping)
          Get the FWD_LOGIN ActionForward object.
protected  org.apache.struts.action.ActionForward loginForward(HttpServletRequest request, org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionErrors errors, String errorKey)
          Get the FWD_LOGIN ActionForward object, and store the error message identified by the errorKey string into the input ActionErrors object.
protected  boolean validateSession(HttpServletRequest request)
          Check if the current session is valid.
 
Methods inherited from class org.apache.struts.action.Action
execute, execute, generateToken, getDataSource, getDataSource, getLocale, getResources, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, perform, perform, resetToken, saveErrors, saveMessages, saveToken, setLocale, setServlet, toHex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FWD_CANCEL

protected static final String FWD_CANCEL
ActionForward cancel string

See Also:
Constant Field Values

FWD_FAILURE

protected static final String FWD_FAILURE
ActionForward failure string

See Also:
Constant Field Values

FWD_LOGIN

protected static final String FWD_LOGIN
ActionForward failure string

See Also:
Constant Field Values

FWD_INVALID_SESSION

protected static final String FWD_INVALID_SESSION
ActionForward invalid session string

See Also:
Constant Field Values

cat

protected org.apache.log4j.Category cat
Log4j category

Constructor Detail

BaseAction

public BaseAction()
Method Detail

loginForward

protected org.apache.struts.action.ActionForward loginForward(HttpServletRequest request,
                                                              org.apache.struts.action.ActionMapping mapping)
Get the FWD_LOGIN ActionForward object.

Parameters:
request - the HttpServletRequest object
mapping - the ActionMapping object
Returns:
Description of the Return Value

loginForward

protected org.apache.struts.action.ActionForward loginForward(HttpServletRequest request,
                                                              org.apache.struts.action.ActionMapping mapping,
                                                              org.apache.struts.action.ActionErrors errors,
                                                              String errorKey)
Get the FWD_LOGIN ActionForward object, and store the error message identified by the errorKey string into the input ActionErrors object.

Parameters:
request - the HttpServletRequest object
mapping - the ActionMapping object
errors - the ActionErrors object
errorKey - a string key identifying a resource properties error string
Returns:
Description of the Return Value

failureForward

protected org.apache.struts.action.ActionForward failureForward(HttpServletRequest request,
                                                                org.apache.struts.action.ActionMapping mapping,
                                                                org.apache.struts.action.ActionErrors errors,
                                                                String errorKey)
Get the FWD_FAILURE ActionForward object, and store the error message identified by the errorKey string into the input ActionErrors object.

Parameters:
request - the HttpServletRequest object
mapping - the ActionMapping object
errors - the ActionErrors object
errorKey - a string key identifying a resource properties error string
Returns:
Description of the Return Value

invalidSessionForward

protected org.apache.struts.action.ActionForward invalidSessionForward(HttpServletRequest request,
                                                                       org.apache.struts.action.ActionMapping mapping,
                                                                       org.apache.struts.action.ActionErrors errors)
Get the FWD_INVALID_SESSION ActionForward object, and store the error message identified by the KEY_INVALID_SESSION key into the input ActionErrors object.

Parameters:
request - the HttpServletRequest object
mapping - the ActionMapping object
errors - the ActionErrors objects
Returns:
Description of the Return Value

getForward

protected org.apache.struts.action.ActionForward getForward(HttpServletRequest request,
                                                            org.apache.struts.action.ActionMapping mapping,
                                                            org.apache.struts.action.ActionErrors errors,
                                                            String forward,
                                                            String errorKey)
Get the ActionForward object related to the input forward string, and store the error message identified by the errorKey string into the input ActionErrors object.

Parameters:
request - the HttpServletRequest object
mapping - the ActionMapping object
errors - the ActionErrors object
forward - the name of the action forward object to retrieve
errorKey - a string key identifying a resource properties error string
Returns:
The forward value

isFailureForward

protected boolean isFailureForward(org.apache.struts.action.ActionForward forward)
Check if the input ActionForward object is a failure forward

Parameters:
forward - the ActionForward object to check

validateSession

protected boolean validateSession(HttpServletRequest request)
Check if the current session is valid.
This is an hook method that returns always true. Make your own action class that extends BaseAction and override this method.

Returns:
true if the current session is valid; false otherwise. This implementation returns true


Copyright © 2002-2004 Power Of Two S.R.L. All Rights Reserved.