org.appfuse.webapp.action
Class BaseAction

java.lang.Object
  extended byorg.apache.struts.action.Action
      extended byorg.apache.struts.actions.DispatchAction
          extended byorg.apache.struts.actions.LookupDispatchAction
              extended byorg.appfuse.webapp.action.BaseAction
Direct Known Subclasses:
EducationAction, ExperienceAction, MembershipAction, ReferenceAction, ResumeAction, ResumeSkillAction, TemplateAction, UserAction

public class BaseAction
extends LookupDispatchAction

Implementation of Action that contains base methods for logging and conducting pre/post perform actions. This class is intended to be a base class for all Struts actions.

View Source

Version:
$Revision: 1.9 $ $Date: 2004/03/31 13:04:24 $
Author:
Matt Raible

Field Summary
protected  ApplicationContext ctx
           
protected static org.apache.commons.logging.Log log
           
static String SECURE
           
 
Fields inherited from class org.apache.struts.actions.LookupDispatchAction
keyMethodMap, localeMap
 
Fields inherited from class org.apache.struts.actions.DispatchAction
clazz, messages, methods, types
 
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  ActionForward cancelled(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
          Method which is dispatched to when the request is a cancel button submit.
protected  boolean checkSsl(ActionMapping mapping, HttpServletRequest request, HttpServletResponse response)
          Method to check and see if https is required for this resource
protected  Object convert(Object o)
           
protected  Object convertDates(Object obj, Object form)
           
protected  Object convertLists(Object o)
           
 ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
          Override the execute method in LookupDispatchAction to parse URLs and forward to methods without parameters.
protected  ActionForm getActionForm(ActionMapping mapping, HttpServletRequest request)
          Convenience method for getting an action form base on it's mapped scope.
 Object getBean(String name)
          Convenience method to bind objects in Actions
 ActionErrors getErrors(HttpServletRequest request)
          Convenience method to initialize errors in a subclass.
 Map getKeyMethodMap()
          Provides the mapping from resource key to method name
protected  String getLookupMapName(HttpServletRequest request, String keyName, ActionMapping mapping)
          Lookup the method name corresponding to the client request's locale.
 ActionMessages getMessages(HttpServletRequest request)
          Convenience method to initialize messages in a subclass.
protected  String getMethodName(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String parameter)
          Returns the method name, given a parameter's value.
 String getResumeId(HttpServletRequest request)
          Convenience method to lookup the user's resumeId
protected  User getUser(HttpSession session)
          Convenience method to get the userForm from the session
protected  void removeFormBean(ActionMapping mapping, HttpServletRequest request)
          Convenience method for removing the obsolete form bean.
protected  void updateFormBean(ActionMapping mapping, HttpServletRequest request, Object form)
          Convenience method to update a formBean in it's scope
 
Methods inherited from class org.apache.struts.actions.DispatchAction
dispatchMethod, getMethod, unspecified
 
Methods inherited from class org.apache.struts.action.Action
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

log

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

SECURE

public static final String SECURE
See Also:
Constant Field Values

ctx

protected ApplicationContext ctx
Constructor Detail

BaseAction

public BaseAction()
Method Detail

getBean

public Object getBean(String name)
Convenience method to bind objects in Actions

Parameters:
name -
Returns:

getResumeId

public String getResumeId(HttpServletRequest request)
                   throws Exception
Convenience method to lookup the user's resumeId

Parameters:
request -
Returns:
Throws:
Exception

getKeyMethodMap

public Map getKeyMethodMap()
Provides the mapping from resource key to method name

Returns:
Resource key / method name map

convertDates

protected Object convertDates(Object obj,
                              Object form)
See Also:
ConvertUtil.convertDates(java.lang.Object, java.lang.Object)

convert

protected Object convert(Object o)
                  throws Exception
Throws:
Exception
See Also:
ConvertUtil.convert(java.lang.Object)

convertLists

protected Object convertLists(Object o)
                       throws Exception
Throws:
Exception
See Also:
ConvertUtil.convertLists(java.lang.Object)

getMessages

public ActionMessages getMessages(HttpServletRequest request)
Convenience method to initialize messages in a subclass.

Parameters:
request - the current request
Returns:
the populated (or empty) messages

getErrors

public ActionErrors getErrors(HttpServletRequest request)
Convenience method to initialize errors in a subclass.

Parameters:
request - the current request
Returns:
the populated (or empty) messages

execute

public ActionForward execute(ActionMapping mapping,
                             ActionForm form,
                             HttpServletRequest request,
                             HttpServletResponse response)
                      throws Exception
Override the execute method in LookupDispatchAction to parse URLs and forward to methods without parameters. Also will forward to unspecified method when no parameter is present. This is based on the following system:

Parameters:
mapping - The ActionMapping used to select this instance
request - The HTTP request we are processing
response - The HTTP response we are creating
form - The optional ActionForm bean for this request (if any)
Returns:
Describes where and how control should be forwarded.
Throws:
Exception - if an error occurs

getActionForm

protected ActionForm getActionForm(ActionMapping mapping,
                                   HttpServletRequest request)
Convenience method for getting an action form base on it's mapped scope.

Parameters:
mapping - The ActionMapping used to select this instance
request - The HTTP request we are processing
Returns:
ActionForm the form from the specifies scope, or null if nothing found

getLookupMapName

protected String getLookupMapName(HttpServletRequest request,
                                  String keyName,
                                  ActionMapping mapping)
                           throws ServletException
Lookup the method name corresponding to the client request's locale.

Parameters:
request - The HTTP request we are processing
keyName - The parameter name to use as the properties key
mapping - The ActionMapping used to select this instance
Returns:
The method's localized name.
Throws:
ServletException - if keyName cannot be resolved
Since:
Struts 1.2.0

getMethodName

protected String getMethodName(ActionMapping mapping,
                               ActionForm form,
                               HttpServletRequest request,
                               HttpServletResponse response,
                               String parameter)
                        throws Exception
Returns the method name, given a parameter's value.

Parameters:
mapping - The ActionMapping used to select this instance
form - The optional ActionForm bean for this request (if any)
request - The HTTP request we are processing
response - The HTTP response we are creating
parameter - The ActionMapping parameter's name
Returns:
The method's name.
Throws:
Exception
Since:
Struts 1.2.0

getUser

protected User getUser(HttpSession session)
Convenience method to get the userForm from the session

Parameters:
session - the current user's session
Returns:
the user's populated form from the session

cancelled

protected ActionForward cancelled(ActionMapping mapping,
                                  ActionForm form,
                                  HttpServletRequest request,
                                  HttpServletResponse response)
                           throws Exception
Method which is dispatched to when the request is a cancel button submit. Subclasses of DispatchAction should override this method if they wish to provide default behavior different than returning null.

Throws:
Exception
Since:
Struts 1.2.0

checkSsl

protected boolean checkSsl(ActionMapping mapping,
                           HttpServletRequest request,
                           HttpServletResponse response)
Method to check and see if https is required for this resource

Parameters:
mapping - The ActionMapping used to select this instance
request - The HTTP request we are processing
response - The HTTP response we are creating
Returns:
boolean true if redirection to SSL is needed

removeFormBean

protected void removeFormBean(ActionMapping mapping,
                              HttpServletRequest request)
Convenience method for removing the obsolete form bean.

Parameters:
mapping - The ActionMapping used to select this instance
request - The HTTP request we are processing

updateFormBean

protected void updateFormBean(ActionMapping mapping,
                              HttpServletRequest request,
                              Object form)
Convenience method to update a formBean in it's scope

Parameters:
mapping - The ActionMapping used to select this instance
request - The HTTP request we are processing
form - The ActionForm


Copyright © 2002-2004