net.sf.oness.common.webapp.controller.action
Class AutoDispatchAction

java.lang.Object
  extended byorg.apache.struts.action.Action
      extended byorg.apache.struts.actions.DispatchAction
          extended byorg.apache.struts.actions.LookupDispatchAction
              extended bynet.sf.oness.common.webapp.controller.action.AutoDispatchAction

public abstract class AutoDispatchAction
extends org.apache.struts.actions.LookupDispatchAction

An abstract Action that dispatches to a method based in the start of the action path.

Version:
$Revision: 1.4 $
Author:
Carlos Sanchez, Matt Raible

Field Summary
 
Fields inherited from class org.apache.struts.actions.LookupDispatchAction
localeMap
 
Fields inherited from class org.apache.struts.actions.DispatchAction
clazz, log, messages, methods, types
 
Fields inherited from class org.apache.struts.action.Action
defaultLocale, servlet
 
Constructor Summary
AutoDispatchAction()
           
 
Method Summary
 org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Override the execute method in LookupDispatchAction to parse URLs and forward to methods without parameters.
 java.lang.Object getBean(java.lang.String name)
          Gets a bean from Spring configuration
protected  java.lang.Object getDynaProperty(org.apache.struts.action.ActionForm actionForm, java.lang.String name)
          Get a property value from a DynaActionForm
 java.util.Map getKeyMethodMap()
          Provides the mapping from resource key to method name.
 
Methods inherited from class org.apache.struts.actions.LookupDispatchAction
getLookupMapName, getMethodName
 
Methods inherited from class org.apache.struts.actions.DispatchAction
cancelled, dispatchMethod, getMethod, unspecified
 
Methods inherited from class org.apache.struts.action.Action
addErrors, addMessages, execute, generateToken, getDataSource, getDataSource, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutoDispatchAction

public AutoDispatchAction()
Method Detail

getBean

public java.lang.Object getBean(java.lang.String name)
Gets a bean from Spring configuration

Parameters:
name - bean name
Returns:
the bean

getKeyMethodMap

public java.util.Map getKeyMethodMap()
Provides the mapping from resource key to method name. Reads the values form the ResourceBundle LookupMethods

Returns:
Resource key / method name map.

execute

public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping,
                                                      org.apache.struts.action.ActionForm form,
                                                      javax.servlet.http.HttpServletRequest request,
                                                      javax.servlet.http.HttpServletResponse response)
                                               throws java.lang.Exception
Override the execute method in LookupDispatchAction to parse URLs and forward to methods without parameters. If the action mapping parameter is present it will be used. If not, it will check if the action path contains any of the values from the Map returned by getKeyMethodMap() and will forward to the method called after that value. If more that one match the result is not specified. Also will forward to unspecified method when no parameter is present. For example if the values from getKeyMethodMap() are edit=edit update=update view=view create=create other=another The following map between paths and methods will be used

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:
java.lang.Exception - if an error occurs

getDynaProperty

protected java.lang.Object getDynaProperty(org.apache.struts.action.ActionForm actionForm,
                                           java.lang.String name)
Get a property value from a DynaActionForm

Parameters:
actionForm - a DynaActionForm
name - name of the property
Returns:


Copyright © 2003-2005 ONess Project. All Rights Reserved.