Java Doc for BaseCommandController.java in  » J2EE » spring-framework-2.0.6 » org » springframework » web » portlet » mvc » 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.portlet.mvc 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.springframework.web.portlet.mvc.AbstractController
   org.springframework.web.portlet.mvc.BaseCommandController

All known Subclasses:   org.springframework.web.portlet.mvc.AbstractCommandController,  org.springframework.web.portlet.mvc.AbstractFormController,
BaseCommandController
abstract public class BaseCommandController extends AbstractController (Code)

Controller implementation which creates an object (the command object) on receipt of a request and attempts to populate this object with request parameters.

This controller is the base for all controllers wishing to populate JavaBeans based on request parameters, validate the content of such JavaBeans using Validator Validators and use custom editors (in the form of java.beans.PropertyEditor PropertyEditors ) to transform objects into strings and vice versa, for example. Three notions are mentioned here:

Command class:
An instance of the command class will be created for each request and populated with request parameters. A command class can basically be any Java class; the only requirement is a no-arg constructor. The command class should preferably be a JavaBean in order to be able to populate bean properties with request parameters.

Populating using request parameters and PropertyEditors:
Upon receiving a request, any BaseCommandController will attempt to fill the command object using the request parameters. This is done using the typical and well-known JavaBeans property notation. When a request parameter named 'firstName' exists, the framework will attempt to call setFirstName([value]) passing the value of the parameter. Nested properties are of course supported. For instance a parameter named 'address.city' will result in a getAddress().setCity([value]) call on the command class.

It's important to realize that you are not limited to String arguments in your JavaBeans. Using the PropertyEditor-notion as supplied by the java.beans package, you will be able to transform Strings to Objects and the other way around. For instance setLocale(Locale loc) is perfectly possible for a request parameter named locale having a value of en, as long as you register the appropriate PropertyEditor in the Controller (see BaseCommandController.initBinder initBinder() for more information on that matter).

Validators: After the controller has successfully populated the command object with parameters from the request, it will use any configured validators to validate the object. Validation results will be put in a org.springframework.validation.Errors Errors object which can be used in a View to render any input problems.

Workflow (and that defined by superclass):
Since this class is an abstract base class for more specific implementation, it does not override the handleRequestInternal() methods and also has no actual workflow. Implementing classes like AbstractFormController AbstractFormController , AbstractCommandController AbstractCommandController , SimpleFormController SimpleFormController and AbstractWizardFormController AbstractWizardFormController provide actual functionality and workflow. More information on workflow performed by superclasses can be found here.

Exposed configuration properties (and those defined by superclass):
name default description
commandName command the name to use when binding the instantiated command class to the request
commandClass null the class to use upon receiving a request and which to fill using the request parameters. What object is used and whether or not it should be created is defined by extending classes and their configuration properties and methods.
validators null Array of Validator beans. The validator will be called at appropriate places in the workflow of subclasses (have a look at those for more info) to validate the command object.
validator null Short-form property for setting only one Validator bean (usually passed in using a <ref bean="beanId"/> property.
validateOnBinding true Indicates whether or not to validate the command object after the object has been populated with request parameters.

Thanks to Rainer Schmitz and Nick Lothian for their suggestions!
author:
   Juergen Hoeller
author:
   John A. Lewis
since:
   2.0



Field Summary
final public static  StringDEFAULT_COMMAND_NAME
    


Method Summary
final protected  PortletRequestDataBinderbindAndValidate(PortletRequest request, Object command)
     Bind the parameters of the given request to the given command object.
final protected  booleancheckCommand(Object command)
     Check if the given command object is a valid for this controller, i.e.
protected  PortletRequestDataBindercreateBinder(PortletRequest request, Object command)
     Create a new binder instance for the given command and request.

Called by bindAndValidate.

final protected  ObjectcreateCommand()
     Create a new command instance for the command class of this controller.
final public  BindingErrorProcessorgetBindingErrorProcessor()
     Return the strategy to use for processing binding errors.
protected  ObjectgetCommand(PortletRequest request)
     Retrieve a command object for the given request.
final public  ClassgetCommandClass()
     Return the command class for this controller.
final public  StringgetCommandName()
     Return the name of the command in the model.
final public  MessageCodesResolvergetMessageCodesResolver()
     Return the strategy to use for resolving errors into message codes.
final public  PropertyEditorRegistrar[]getPropertyEditorRegistrars()
     Return the PropertyEditorRegistrars to be applied to every DataBinder that this controller uses.
final protected  ObjectgetRenderCommand(RenderRequest request)
     Get the command object cached for the render phase.
protected  StringgetRenderCommandSessionAttributeName()
     Return the name of the session attribute that holds the render phase command object for this form controller.
final protected  BindExceptiongetRenderErrors(RenderRequest request)
     Get the bind and validation errors cached for the render phase.
protected  StringgetRenderErrorsSessionAttributeName()
     Return the name of the session attribute that holds the render phase command object for this form controller.
final public  ValidatorgetValidator()
    
final public  Validator[]getValidators()
     Return the Validators for this controller.
protected  voidinitApplicationContext()
    
protected  voidinitBinder(PortletRequest request, PortletRequestDataBinder 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.

final public  booleanisValidateOnBinding()
     Return if the Validator should get applied when binding.
protected  voidonBind(PortletRequest request, Object command, BindException errors)
     Callback for custom post-processing in terms of binding.
protected  voidonBind(PortletRequest request, Object command)
     Callback for custom post-processing in terms of binding.
protected  voidonBindAndValidate(PortletRequest request, Object command, BindException errors)
     Callback for custom post-processing in terms of binding and validation.
final protected  voidprepareBinder(PortletRequestDataBinder binder)
     Prepare the given binder, applying the specified MessageCodesResolver, BindingErrorProcessor and PropertyEditorRegistrars (if any).
final public  voidsetBindingErrorProcessor(BindingErrorProcessor bindingErrorProcessor)
     Set the strategy to use for processing binding errors, that is, required field errors and PropertyAccessExceptions.

Default is null, i.e.

final public  voidsetCommandClass(Class commandClass)
     Set the command class for this controller.
final public  voidsetCommandName(String commandName)
     Set the name of the command in the model.
final public  voidsetMessageCodesResolver(MessageCodesResolver messageCodesResolver)
     Set the strategy to use for resolving errors into message codes. Applies the given strategy to all data binders used by this controller.

Default is null, i.e.

final public  voidsetPropertyEditorRegistrar(PropertyEditorRegistrar propertyEditorRegistrar)
     Specify a single PropertyEditorRegistrar to be applied to every DataBinder that this controller uses.
final public  voidsetPropertyEditorRegistrars(PropertyEditorRegistrar[] propertyEditorRegistrars)
     Specify one or more PropertyEditorRegistrars to be applied to every DataBinder that this controller uses.
final protected  voidsetRenderCommandAndErrors(ActionRequest request, Object command, BindException errors)
     Set the command object and errors object for the render phase.
final public  voidsetValidateOnBinding(boolean validateOnBinding)
     Set if the Validator should get applied when binding.
final public  voidsetValidator(Validator validator)
     Set the primary Validator for this controller.
final public  voidsetValidators(Validator[] validators)
     Set the Validators for this controller.
protected  booleansuppressBinding(PortletRequest request)
     Return whether to suppress binding for the given request.

Default implementation always returns "false".

protected  booleansuppressValidation(PortletRequest request)
     Return whether to suppress validation for the given request.

Default implementation always returns "false".

protected  booleanuseDirectFieldAccess()
     Determine whether to use direct field access instead of bean property access. Applied by prepareBinder.

Default is "false".


Field Detail
DEFAULT_COMMAND_NAME
final public static String DEFAULT_COMMAND_NAME(Code)





Method Detail
bindAndValidate
final protected PortletRequestDataBinder bindAndValidate(PortletRequest request, Object command) throws Exception(Code)
Bind the parameters of the given request to the given command object.
Parameters:
  request - current portlet request
Parameters:
  command - the command to bind onto the PortletRequestDataBinder instance for additional custom validation
throws:
  Exception - in case of invalid state or arguments



checkCommand
final protected boolean checkCommand(Object command)(Code)
Check if the given command object is a valid for this controller, i.e. its command class.
Parameters:
  command - the command object to check if the command object is valid for this controller



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

Called by bindAndValidate. Can be overridden to plug in custom PortletRequestDataBinder instances.

The default implementation creates a standard PortletRequestDataBinder and invokes prepareBinder and initBinder.

Note that neither prepareBinder nor initBinder will be invoked automatically if you override this method! Call those methods at appropriate points of your overridden method.
Parameters:
  request - current portlet request
Parameters:
  command - the command to bind onto the new binder instance
throws:
  Exception - in case of invalid state or arguments
See Also:   BaseCommandController.bindAndValidate
See Also:   BaseCommandController.prepareBinder
See Also:   BaseCommandController.initBinder




createCommand
final protected Object createCommand() throws Exception(Code)
Create a new command instance for the command class of this controller.

This implementation uses BeanUtils.instantiateClass, so the command needs to have a no-arg constructor (supposed to be public, but not required to). the new command instance
throws:
  Exception - if the command object could not be instantiated
See Also:   org.springframework.beans.BeanUtils.instantiateClass(Class)




getBindingErrorProcessor
final public BindingErrorProcessor getBindingErrorProcessor()(Code)
Return the strategy to use for processing binding errors.



getCommand
protected Object getCommand(PortletRequest request) throws Exception(Code)
Retrieve a command object for the given request.

Default implementation calls createCommand. Subclasses can override this.
Parameters:
  request - current portlet request object command to bind onto
See Also:   BaseCommandController.createCommand




getCommandClass
final public Class getCommandClass()(Code)
Return the command class for this controller.



getCommandName
final public String getCommandName()(Code)
Return the name of the command in the model.



getMessageCodesResolver
final public MessageCodesResolver getMessageCodesResolver()(Code)
Return the strategy to use for resolving errors into message codes.



getPropertyEditorRegistrars
final public PropertyEditorRegistrar[] getPropertyEditorRegistrars()(Code)
Return the PropertyEditorRegistrars to be applied to every DataBinder that this controller uses.



getRenderCommand
final protected Object getRenderCommand(RenderRequest request) throws PortletException(Code)
Get the command object cached for the render phase.
See Also:   BaseCommandController.getRenderErrors
See Also:   BaseCommandController.getRenderCommandSessionAttributeName
See Also:   BaseCommandController.setRenderCommandAndErrors



getRenderCommandSessionAttributeName
protected String getRenderCommandSessionAttributeName()(Code)
Return the name of the session attribute that holds the render phase command object for this form controller. the name of the render phase command object session attribute
See Also:   javax.portlet.PortletSession.getAttribute



getRenderErrors
final protected BindException getRenderErrors(RenderRequest request) throws PortletException(Code)
Get the bind and validation errors cached for the render phase.
See Also:   BaseCommandController.getRenderCommand
See Also:   BaseCommandController.getRenderErrorsSessionAttributeName
See Also:   BaseCommandController.setRenderCommandAndErrors



getRenderErrorsSessionAttributeName
protected String getRenderErrorsSessionAttributeName()(Code)
Return the name of the session attribute that holds the render phase command object for this form controller. the name of the render phase command object session attribute
See Also:   javax.portlet.PortletSession.getAttribute



getValidator
final public Validator getValidator()(Code)
the primary Validator for this controller.



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



initApplicationContext
protected void initApplicationContext()(Code)



initBinder
protected void initBinder(PortletRequest request, PortletRequestDataBinder 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.
Parameters:
  request - current portlet request
Parameters:
  binder - new binder instance
throws:
  Exception - in case of invalid state or arguments
See Also:   BaseCommandController.createBinder
See Also:   org.springframework.validation.DataBinder.registerCustomEditor
See Also:   org.springframework.beans.propertyeditors.CustomDateEditor




isValidateOnBinding
final public boolean isValidateOnBinding()(Code)
Return if the Validator should get applied when binding.



onBind
protected void onBind(PortletRequest request, Object command, BindException errors) throws Exception(Code)
Callback for custom post-processing in terms of binding. Called on each submit, after standard binding but before validation.

Default implementation delegates to onBind(request, command).
Parameters:
  request - current portlet request
Parameters:
  command - the command object to perform further binding on
Parameters:
  errors - validation errors holder, allowing for additionalcustom registration of binding errors
throws:
  Exception - in case of invalid state or arguments
See Also:   BaseCommandController.bindAndValidate
See Also:   BaseCommandController.onBind(PortletRequest,Object)




onBind
protected void onBind(PortletRequest request, Object command) throws Exception(Code)
Callback for custom post-processing in terms of binding. Called by the default implementation of the onBind version with all parameters, after standard binding but before validation.

Default implementation is empty.
Parameters:
  request - current portlet request
Parameters:
  command - the command object to perform further binding on
throws:
  Exception - in case of invalid state or arguments
See Also:   BaseCommandController.onBind(PortletRequest,Object,BindException)




onBindAndValidate
protected void onBindAndValidate(PortletRequest request, Object command, BindException errors) throws Exception(Code)
Callback for custom post-processing in terms of binding and validation. Called on each submit, after standard binding and validation, but before error evaluation.

Default implementation is empty.
Parameters:
  request - current portlet request
Parameters:
  command - the command object, still allowing for further binding
Parameters:
  errors - validation errors holder, allowing for additionalcustom validation
throws:
  Exception - in case of invalid state or arguments
See Also:   BaseCommandController.bindAndValidate
See Also:   org.springframework.validation.Errors




prepareBinder
final protected void prepareBinder(PortletRequestDataBinder binder)(Code)
Prepare the given binder, applying the specified MessageCodesResolver, BindingErrorProcessor and PropertyEditorRegistrars (if any). Called by createBinder.
Parameters:
  binder - the new binder instance
See Also:   BaseCommandController.createBinder
See Also:   BaseCommandController.setMessageCodesResolver
See Also:   BaseCommandController.setBindingErrorProcessor



setBindingErrorProcessor
final public void setBindingErrorProcessor(BindingErrorProcessor bindingErrorProcessor)(Code)
Set the strategy to use for processing binding errors, that is, required field errors and PropertyAccessExceptions.

Default is null, i.e. using the default strategy of the data binder.
See Also:   BaseCommandController.createBinder
See Also:   org.springframework.validation.DataBinder.setBindingErrorProcessor




setCommandClass
final public void setCommandClass(Class commandClass)(Code)
Set the command class for this controller. An instance of this class gets populated and validated on each request.



setCommandName
final public void setCommandName(String commandName)(Code)
Set the name of the command in the model. The command object will be included in the model under this name.



setMessageCodesResolver
final public void setMessageCodesResolver(MessageCodesResolver messageCodesResolver)(Code)
Set the strategy to use for resolving errors into message codes. Applies the given strategy to all data binders used by this controller.

Default is null, i.e. using the default strategy of the data binder.
See Also:   BaseCommandController.createBinder
See Also:   org.springframework.validation.DataBinder.setMessageCodesResolver




setPropertyEditorRegistrar
final public void setPropertyEditorRegistrar(PropertyEditorRegistrar propertyEditorRegistrar)(Code)
Specify a single PropertyEditorRegistrar to be applied to every DataBinder that this controller uses.

Allows for factoring out the registration of PropertyEditors to separate objects, as an alternative to initBinder.
See Also:   BaseCommandController.initBinder




setPropertyEditorRegistrars
final public void setPropertyEditorRegistrars(PropertyEditorRegistrar[] propertyEditorRegistrars)(Code)
Specify one or more PropertyEditorRegistrars to be applied to every DataBinder that this controller uses.

Allows for factoring out the registration of PropertyEditors to separate objects, as alternative to initBinder.
See Also:   BaseCommandController.initBinder




setRenderCommandAndErrors
final protected void setRenderCommandAndErrors(ActionRequest request, Object command, BindException errors) throws Exception(Code)
Set the command object and errors object for the render phase.
Parameters:
  request - the current action request
Parameters:
  command - the command object to preserve for the render phase
Parameters:
  errors - the errors from binding and validation to preserve for the render phase
See Also:   BaseCommandController.getRenderCommand
See Also:   BaseCommandController.getRenderErrors
See Also:   BaseCommandController.getRenderCommandSessionAttributeName
See Also:   BaseCommandController.getRenderErrorsSessionAttributeName



setValidateOnBinding
final public void setValidateOnBinding(boolean validateOnBinding)(Code)
Set if the Validator should get applied when binding.



setValidator
final public void setValidator(Validator validator)(Code)
Set the primary Validator for this controller. The Validator must support the specified command class. If there are one or more existing validators set already when this method is called, only the specified validator will be kept. Use BaseCommandController.setValidators(Validator[]) to set multiple validators.



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



suppressBinding
protected boolean suppressBinding(PortletRequest request)(Code)
Return whether to suppress binding for the given request.

Default implementation always returns "false". Can be overridden in subclasses to suppress validation, for example, if a special request parameter is set.
Parameters:
  request - current portlet request whether to suppress binding for the given request
See Also:   BaseCommandController.suppressValidation




suppressValidation
protected boolean suppressValidation(PortletRequest request)(Code)
Return whether to suppress validation for the given request.

Default implementation always returns "false". Can be overridden in subclasses to suppress validation, for example, if a special request parameter is set.
Parameters:
  request - current portlet request whether to suppress validation for the given request




useDirectFieldAccess
protected boolean useDirectFieldAccess()(Code)
Determine whether to use direct field access instead of bean property access. Applied by prepareBinder.

Default is "false". Can be overridden in subclasses.
See Also:   BaseCommandController.prepareBinder
See Also:   org.springframework.validation.DataBinder.initDirectFieldAccess




Methods inherited from org.springframework.web.portlet.mvc.AbstractController
final public void handleActionRequest(ActionRequest request, ActionResponse response) throws Exception(Code)(Java Doc)
protected void handleActionRequestInternal(ActionRequest request, ActionResponse response) throws Exception(Code)(Java Doc)
final public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response) throws Exception(Code)(Java Doc)
protected ModelAndView handleRenderRequestInternal(RenderRequest request, RenderResponse response) throws Exception(Code)(Java Doc)
public boolean isRenderWhenMinimized()(Code)(Java Doc)
final public boolean isSynchronizeOnSession()(Code)(Java Doc)
public void setRenderWhenMinimized(boolean renderWhenMinimized)(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.