net.sourceforge.xconf.toolbox.spring.action
Class ActionCommandController
java.lang.Object
org.springframework.context.support.ApplicationObjectSupport
org.springframework.web.context.support.WebApplicationObjectSupport
org.springframework.web.servlet.support.WebContentGenerator
org.springframework.web.servlet.mvc.AbstractController
org.springframework.web.servlet.mvc.BaseCommandController
org.springframework.web.servlet.mvc.AbstractCommandController
net.sourceforge.xconf.toolbox.spring.action.ActionCommandController
- All Implemented Interfaces:
- ApplicationContextAware, ServletContextAware, Controller
public class ActionCommandController
- extends AbstractCommandController
This controller uses commands like WebWork/Maverick-style prototypes that get populated with request parameters,
executed to determine a view, and thrown away afterwards. The commands can be simple classes created via reflection
or more complex (non-singleton) beans retrieved from an application context. The method to be executed on the
command should be public, no-arg and should return an ActionResult instance.
- Author:
- Tom Czarniecki
- See Also:
Action,
ActionResult
|
Method Summary |
protected ModelAndView |
createModelAndView(ActionResult result,
BindException errors)
|
protected Object |
getCommand(HttpServletRequest request)
Delegates to the configured command bean name resolver (and retrieves the bean from the
current application context) if present, otherwise creates a command using the default
superclass implementation. |
protected ModelAndView |
handle(HttpServletRequest request,
HttpServletResponse response,
Object command,
BindException errors)
Injects all aware setters, checks for binding and validation errors, uses the configured
command method name resolver to retrieve the name of the action method to invoke, then
invokes the action method and uses the returned ActionResult to create a ModelAndView. |
protected ModelAndView |
handleMethodMissing(HttpServletRequest request,
HttpServletResponse response,
NoSuchRequestHandlingMethodException error)
Handler invoked when unable to resolve an action method. |
protected void |
initBinder(HttpServletRequest request,
ServletRequestDataBinder binder)
Delegates to the configured BinderRegistrar if present. |
protected ActionResult |
invokeAction(Object command,
String methodName)
|
protected void |
processAwareSetters(Object command,
HttpServletRequest request,
HttpServletResponse response,
BindException errors)
|
void |
setBinderRegistrar(BinderRegistrar registrar)
|
void |
setCommandBeanName(String beanName)
|
void |
setCommandBeanNameResolver(MethodNameResolver resolver)
|
void |
setCommandMethodMissingViewName(String viewName)
|
void |
setCommandMethodName(String methodName)
|
void |
setCommandMethodNameResolver(MethodNameResolver resolver)
|
| Methods inherited from class org.springframework.web.servlet.mvc.BaseCommandController |
bindAndValidate, checkCommand, createBinder, createCommand, getBindingErrorProcessor, getCommandClass, getCommandName, getMessageCodesResolver, getPropertyEditorRegistrars, getValidator, getValidators, initApplicationContext, isValidateOnBinding, onBind, onBind, onBindAndValidate, prepareBinder, setBindingErrorProcessor, setCommandClass, setCommandName, setMessageCodesResolver, setPropertyEditorRegistrar, setPropertyEditorRegistrars, setValidateOnBinding, setValidator, setValidators, suppressBinding, suppressValidation, suppressValidation, suppressValidation, useDirectFieldAccess |
| Methods inherited from class org.springframework.web.servlet.support.WebContentGenerator |
applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, getCacheSeconds, getSupportedMethods, isRequireSession, isUseCacheControlHeader, isUseExpiresHeader, preventCaching, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseExpiresHeader |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ACTION_METHOD_NAME
public static final String ACTION_METHOD_NAME
- Default method that will be invoked on any command object (ie. action) used by this controller.
- See Also:
- Constant Field Values
ActionCommandController
public ActionCommandController()
setBinderRegistrar
public void setBinderRegistrar(BinderRegistrar registrar)
setCommandBeanName
public void setCommandBeanName(String beanName)
setCommandBeanNameResolver
public void setCommandBeanNameResolver(MethodNameResolver resolver)
setCommandMethodName
public void setCommandMethodName(String methodName)
setCommandMethodNameResolver
public void setCommandMethodNameResolver(MethodNameResolver resolver)
setCommandMethodMissingViewName
public void setCommandMethodMissingViewName(String viewName)
initBinder
protected void initBinder(HttpServletRequest request,
ServletRequestDataBinder binder)
throws Exception
- Delegates to the configured
BinderRegistrar if present.
- Overrides:
initBinder in class BaseCommandController
- Throws:
Exception
getCommand
protected Object getCommand(HttpServletRequest request)
throws Exception
- Delegates to the configured command bean name resolver (and retrieves the bean from the
current application context) if present, otherwise creates a command using the default
superclass implementation.
- Overrides:
getCommand in class BaseCommandController
- Throws:
Exception- See Also:
setCommandBeanNameResolver(MethodNameResolver)
handle
protected ModelAndView handle(HttpServletRequest request,
HttpServletResponse response,
Object command,
BindException errors)
throws Exception
- Injects all aware setters, checks for binding and validation errors, uses the configured
command method name resolver to retrieve the name of the action method to invoke, then
invokes the action method and uses the returned ActionResult to create a ModelAndView.
- Specified by:
handle in class AbstractCommandController
- Throws:
Exception
processAwareSetters
protected void processAwareSetters(Object command,
HttpServletRequest request,
HttpServletResponse response,
BindException errors)
invokeAction
protected ActionResult invokeAction(Object command,
String methodName)
throws Exception
- Throws:
Exception
createModelAndView
protected ModelAndView createModelAndView(ActionResult result,
BindException errors)
- See Also:
ActionResult.isAppendErrors()
handleMethodMissing
protected ModelAndView handleMethodMissing(HttpServletRequest request,
HttpServletResponse response,
NoSuchRequestHandlingMethodException error)
throws Exception
- Handler invoked when unable to resolve an action method. If the
setCommandMethodMissingViewName(String)
has been provided, this method will return a ModelAndView to display the given view, otherwise this method
sends a 404 error message back to the browser.
- Throws:
Exception- See Also:
HttpServletResponse.SC_NOT_FOUND
Copyright © 2007 Thomas Czarniecki. All Rights Reserved.