Java Doc for MultiActionController.java in  » J2EE » spring-framework-2.0.6 » org » springframework » web » servlet » mvc » multiaction » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.0.6 » org.springframework.web.servlet.mvc.multiaction 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.springframework.web.servlet.mvc.AbstractController
   org.springframework.web.servlet.mvc.multiaction.MultiActionController

MultiActionController
public class MultiActionController extends AbstractController implements LastModified(Code)
Controller implementation that allows multiple request types to be handled by the same class. Subclasses of this class can handle several different types of request with methods of the form
 (ModelAndView | Map | void) actionName(HttpServletRequest request, HttpServletResponse response);
May take a third parameter HttpSession in which an existing session will be required, or a third parameter of an arbitrary class that gets treated as command (i.e. an instance of the class gets created, and request parameters get bound to it)

These methods can throw any kind of exception, but should only let propagate those that they consider fatal, or which their class or superclass is prepared to catch by implementing an exception handler.

When returning just a Map instance view name translation will be used to generate the view name. The configured org.springframework.web.servlet.RequestToViewNameTranslator will be used to determine the view name.

When returning void a return value of null is assumed meaning that the handler method is responsible for writing the response directly to the supplied HttpServletResponse .

This model allows for rapid coding, but loses the advantage of compile-time checking. It is similar to a Struts 1.1 DispatchAction, but more sophisticated. Also supports delegation to another object.

An implementation of the MethodNameResolver interface defined in this package should return a method name for a given request, based on any aspect of the request, such as its URL or an "action" parameter. The actual strategy can be configured via the "methodNameResolver" bean property, for each MultiActionController.

The default MethodNameResolver is InternalPathMethodNameResolver; further included strategies are PropertiesMethodNameResolver and ParameterMethodNameResolver.

Subclasses can implement custom exception handler methods with names such as:

 ModelAndView anyMeaningfulName(HttpServletRequest request, HttpServletResponse response, ExceptionClass exception);
The third parameter can be any subclass or Exception or RuntimeException.

There can also be an optional lastModified method for handlers, of signature:

 long anyMeaningfulNameLastModified(HttpServletRequest request)
If such a method is present, it will be invoked. Default return from getLastModified is -1, meaning that the content must always be regenerated.

Note that method overloading isn't allowed.

See also the description of the workflow performed by AbstractController the superclass (in that section of the class level Javadoc entitled 'workflow').

Note: For maximum data binding flexibility, consider direct usage of a ServletRequestDataBinder in your controller method, instead of relying on a declared command argument. This allows for full control over the entire binder setup and usage, including the invocation of Validators and the subsequent evaluation of binding/validation errors.
author:
   Rod Johnson
author:
   Juergen Hoeller
author:
   Colin Sampaleanu
author:
   Rob Harrop
See Also:   MethodNameResolver
See Also:   InternalPathMethodNameResolver
See Also:   PropertiesMethodNameResolver
See Also:   ParameterMethodNameResolver
See Also:   org.springframework.web.servlet.mvc.LastModified.getLastModified
See Also:   org.springframework.web.bind.ServletRequestDataBinder



Field Summary
final public static  StringDEFAULT_COMMAND_NAME
    
final public static  StringLAST_MODIFIED_METHOD_SUFFIX
    
final public static  StringPAGE_NOT_FOUND_LOG_CATEGORY
    
final protected static  LogpageNotFoundLogger
    

Constructor Summary
public  MultiActionController()
     Constructor for MultiActionController that looks for handler methods in the present subclass.
public  MultiActionController(Object delegate)
     Constructor for MultiActionController that looks for handler methods in delegate, rather than a subclass of this class.

Method Summary
protected  voidbind(HttpServletRequest request, Object command)
    
protected  ServletRequestDataBindercreateBinder(HttpServletRequest request, Object command)
     Create a new binder instance for the given command and request.

Called by bind.

protected  StringgetCommandName(Object command)
     Return the command name to use for the given command object.
protected  MethodgetExceptionHandler(Throwable exception)
     Determine the exception handler method for the given exception.
public  longgetLastModified(HttpServletRequest request)
     Try to find an XXXXLastModified method, where XXXX is the name of a handler.
final public  MethodNameResolvergetMethodNameResolver()
     Return the MethodNameResolver used by this class.
final public  Validator[]getValidators()
     Return the Validators for this controller.
protected  ModelAndViewhandleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException ex, HttpServletRequest request, HttpServletResponse response)
     Handle the case where no request handler method was found.
protected  ModelAndViewhandleRequestInternal(HttpServletRequest request, HttpServletResponse response)
     Determine a handler method and invoke it.
protected  voidinitBinder(HttpServletRequest request, ServletRequestDataBinder binder)
     Initialize the given binder instance, for example with custom editors. Called by createBinder.

This method allows you to register custom editors for certain fields of your command class.

protected  voidinitBinder(ServletRequest request, ServletRequestDataBinder binder)
     Initialize the given binder instance, for example with custom editors.
final protected  ModelAndViewinvokeNamedMethod(String methodName, HttpServletRequest request, HttpServletResponse response)
     Invokes the named method.
protected  ObjectnewCommandObject(Class clazz)
     Create a new command object of the given class.
final public  voidsetDelegate(Object delegate)
     Set the delegate used by this class.
final public  voidsetMethodNameResolver(MethodNameResolver methodNameResolver)
     Set the method name resolver that this class should use.
final public  voidsetValidators(Validator[] validators)
     Set the Validators for this controller.

Field Detail
DEFAULT_COMMAND_NAME
final public static String DEFAULT_COMMAND_NAME(Code)
Default command name used for binding command objects: "command"



LAST_MODIFIED_METHOD_SUFFIX
final public static String LAST_MODIFIED_METHOD_SUFFIX(Code)
Suffix for last-modified methods



PAGE_NOT_FOUND_LOG_CATEGORY
final public static String PAGE_NOT_FOUND_LOG_CATEGORY(Code)
Log category to use when no mapped handler is found for a request



pageNotFoundLogger
final protected static Log pageNotFoundLogger(Code)
Additional logger to use when no mapped handler is found for a request




Constructor Detail
MultiActionController
public MultiActionController()(Code)
Constructor for MultiActionController that looks for handler methods in the present subclass. Caches methods for quick invocation later. This class's use of reflection will impose little overhead at runtime.



MultiActionController
public MultiActionController(Object delegate)(Code)
Constructor for MultiActionController that looks for handler methods in delegate, rather than a subclass of this class. Caches methods for quick invocation later.
Parameters:
  delegate - handler object. This doesn't need to implement any particularinterface, as everything is done using reflection.




Method Detail
bind
protected void bind(HttpServletRequest request, Object command) throws Exception(Code)
Bind request parameters onto the given command bean
Parameters:
  request - request from which parameters will be bound
Parameters:
  command - command object, that must be a JavaBean
throws:
  Exception - in case of invalid state or arguments



createBinder
protected ServletRequestDataBinder createBinder(HttpServletRequest request, Object command) throws Exception(Code)
Create a new binder instance for the given command and request.

Called by bind. Can be overridden to plug in custom ServletRequestDataBinder subclasses.

Default implementation creates a standard ServletRequestDataBinder, and invokes initBinder. Note that initBinder will not be invoked if you override this method!
Parameters:
  request - current HTTP request
Parameters:
  command - the command to bind onto the new binder instance
throws:
  Exception - in case of invalid state or arguments
See Also:   MultiActionController.bind
See Also:   MultiActionController.initBinder




getCommandName
protected String getCommandName(Object command)(Code)
Return the command name to use for the given command object. Default is "command".
Parameters:
  command - the command object the command name to use
See Also:   MultiActionController.DEFAULT_COMMAND_NAME



getExceptionHandler
protected Method getExceptionHandler(Throwable exception)(Code)
Determine the exception handler method for the given exception. Can return null if not found. a handler for the given exception type, or null
Parameters:
  exception - the exception to handle



getLastModified
public long getLastModified(HttpServletRequest request)(Code)
Try to find an XXXXLastModified method, where XXXX is the name of a handler. Return -1, indicating that content must be updated, if there's no such handler.
See Also:   org.springframework.web.servlet.mvc.LastModified.getLastModified(HttpServletRequest)



getMethodNameResolver
final public MethodNameResolver getMethodNameResolver()(Code)
Return the MethodNameResolver used by this class.



getValidators
final public Validator[] getValidators()(Code)
Return the Validators for this controller.



handleNoSuchRequestHandlingMethod
protected ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException ex, HttpServletRequest request, HttpServletResponse response) throws Exception(Code)
Handle the case where no request handler method was found.

The default implementation logs a warning and sends an HTTP 404 error. Alternatively, a fallback view could be chosen, or the NoSuchRequestHandlingMethodException could be rethrown as-is.
Parameters:
  ex - the NoSuchRequestHandlingMethodException to be handled
Parameters:
  request - current HTTP request
Parameters:
  response - current HTTP response a ModelAndView to render, or null if handled directly
throws:
  Exception - an Exception that should be thrown as result of the servlet request




handleRequestInternal
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception(Code)
Determine a handler method and invoke it.
See Also:   MethodNameResolver.getHandlerMethodName
See Also:   MultiActionController.invokeNamedMethod
See Also:   MultiActionController.handleNoSuchRequestHandlingMethod



initBinder
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception(Code)
Initialize the given binder instance, for example with custom editors. Called by createBinder.

This method allows you to register custom editors for certain fields of your command class. For instance, you will be able to transform Date objects into a String pattern and back, in order to allow your JavaBeans to have Date properties and still be able to set and display them in an HTML interface.

Default implementation is empty.

Note: the command object is not directly passed to this method, but it's available via org.springframework.validation.DataBinder.getTarget
Parameters:
  request - current HTTP request
Parameters:
  binder - new binder instance
throws:
  Exception - in case of invalid state or arguments
See Also:   MultiActionController.createBinder
See Also:   org.springframework.validation.DataBinder.registerCustomEditor
See Also:   org.springframework.beans.propertyeditors.CustomDateEditor




initBinder
protected void initBinder(ServletRequest request, ServletRequestDataBinder binder) throws Exception(Code)
Initialize the given binder instance, for example with custom editors.



invokeNamedMethod
final protected ModelAndView invokeNamedMethod(String methodName, HttpServletRequest request, HttpServletResponse response) throws Exception(Code)
Invokes the named method.

Uses a custom exception handler if possible; otherwise, throw an unchecked exception; wrap a checked exception or Throwable.




newCommandObject
protected Object newCommandObject(Class clazz) throws Exception(Code)
Create a new command object of the given class.

This implementation uses BeanUtils.instantiateClass, so commands need to have public no-arg constructors. Subclasses can override this implementation if desired.
throws:
  Exception - if the command object could not be instantiated
See Also:   org.springframework.beans.BeanUtils.instantiateClass(Class)




setDelegate
final public void setDelegate(Object delegate)(Code)
Set the delegate used by this class. The default is this, assuming that handler methods have been added by a subclass.

This method does not get invoked once the class is configured.
Parameters:
  delegate - an object containing handler methods




setMethodNameResolver
final public void setMethodNameResolver(MethodNameResolver methodNameResolver)(Code)
Set the method name resolver that this class should use. Allows parameterization of handler method mappings.



setValidators
final public void setValidators(Validator[] validators)(Code)
Set the Validators for this controller. The Validator must support the specified command class.



Methods inherited from org.springframework.web.servlet.mvc.AbstractController
final public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception(Code)(Java Doc)
abstract protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception(Code)(Java Doc)
final public boolean isSynchronizeOnSession()(Code)(Java Doc)
final public void setSynchronizeOnSession(boolean synchronizeOnSession)(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.