Java Doc for WebDataBinder.java in  » J2EE » spring-framework-2.5 » org » springframework » web » bind » 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.5 » org.springframework.web.bind 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.validation.DataBinder
      org.springframework.web.bind.WebDataBinder

WebDataBinder
public class WebDataBinder extends DataBinder (Code)
Special DataBinder for data binding from web request parameters to JavaBean objects. Designed for web environments, but not dependent on the Servlet API; serves as base class for more specific DataBinder variants, such as org.springframework.web.bind.ServletRequestDataBinder .

Includes support for field markers which address a common problem with HTML checkboxes and select options: detecting that a field was part of the form, but did not generate a request parameter because it was empty. A field marker allows to detect that state and reset the corresponding bean property accordingly.
author:
   Juergen Hoeller
since:
   1.2
See Also:   WebDataBinder.registerCustomEditor
See Also:   WebDataBinder.setAllowedFields
See Also:   WebDataBinder.setRequiredFields
See Also:   WebDataBinder.setFieldMarkerPrefix
See Also:   ServletRequestDataBinder



Field Summary
final public static  StringDEFAULT_FIELD_MARKER_PREFIX
     Default prefix that field marker parameters start with, followed by the field name: e.g.

Constructor Summary
public  WebDataBinder(Object target)
     Create a new WebDataBinder instance, with default object name.
public  WebDataBinder(Object target, String objectName)
     Create a new WebDataBinder instance.

Method Summary
protected  voidbindMultipartFiles(Map multipartFiles, MutablePropertyValues mpvs)
     Bind the multipart files contained in the given request, if any (in case of a multipart request).
protected  voidcheckFieldMarkers(MutablePropertyValues mpvs)
     Check the given property values for field markers, i.e.
protected  voiddoBind(MutablePropertyValues mpvs)
     This implementation performs a field marker check before delegating to the superclass binding process.
protected  ObjectgetEmptyValue(String field, Class fieldType)
     Determine an empty value for the specified field.
public  StringgetFieldMarkerPrefix()
     Return the prefix for parameters that mark potentially empty fields.
public  booleanisBindEmptyMultipartFiles()
     Return whether to bind empty MultipartFile parameters.
public  voidsetBindEmptyMultipartFiles(boolean bindEmptyMultipartFiles)
     Set whether to bind empty MultipartFile parameters.
public  voidsetFieldMarkerPrefix(String fieldMarkerPrefix)
     Specify a prefix that can be used for parameters that mark potentially empty fields, having "prefix + field" as name.

Field Detail
DEFAULT_FIELD_MARKER_PREFIX
final public static String DEFAULT_FIELD_MARKER_PREFIX(Code)
Default prefix that field marker parameters start with, followed by the field name: e.g. "_subscribeToNewsletter" for a field "subscribeToNewsletter".

Such a marker parameter indicates that the field was visible, that is, existed in the form that caused the submission. If no corresponding field value parameter was found, the field will be reset. The value of the field marker parameter does not matter in this case; an arbitrary value can be used. This is particularly useful for HTML checkboxes and select options.
See Also:   WebDataBinder.setFieldMarkerPrefix





Constructor Detail
WebDataBinder
public WebDataBinder(Object target)(Code)
Create a new WebDataBinder instance, with default object name.
Parameters:
  target - target object to bind onto
See Also:   WebDataBinder.DEFAULT_OBJECT_NAME



WebDataBinder
public WebDataBinder(Object target, String objectName)(Code)
Create a new WebDataBinder instance.
Parameters:
  target - target object to bind onto
Parameters:
  objectName - objectName of the target object




Method Detail
bindMultipartFiles
protected void bindMultipartFiles(Map multipartFiles, MutablePropertyValues mpvs)(Code)
Bind the multipart files contained in the given request, if any (in case of a multipart request).

Multipart files will only be added to the property values if they are not empty or if we're configured to bind empty multipart files too.
Parameters:
  multipartFiles - Map of field name String to MultipartFile object
Parameters:
  mpvs - the property values to be bound (can be modified)
See Also:   org.springframework.web.multipart.MultipartFile
See Also:   WebDataBinder.setBindEmptyMultipartFiles




checkFieldMarkers
protected void checkFieldMarkers(MutablePropertyValues mpvs)(Code)
Check the given property values for field markers, i.e. for fields that start with the field marker prefix.

The existence of a field marker indicates that the specified field existed in the form. If the property values do not contain a corresponding field value, the field will be considered as empty and will be reset appropriately.
Parameters:
  mpvs - the property values to be bound (can be modified)
See Also:   WebDataBinder.getFieldMarkerPrefix
See Also:   WebDataBinder.getEmptyValue(String,Class)




doBind
protected void doBind(MutablePropertyValues mpvs)(Code)
This implementation performs a field marker check before delegating to the superclass binding process.
See Also:   WebDataBinder.checkFieldMarkers



getEmptyValue
protected Object getEmptyValue(String field, Class fieldType)(Code)
Determine an empty value for the specified field.

Default implementation returns Boolean.FALSE for boolean fields and an empty array of array types. Else, null is used as default.
Parameters:
  field - the name of the field
Parameters:
  fieldType - the type of the field the empty value (for most fields: null)




getFieldMarkerPrefix
public String getFieldMarkerPrefix()(Code)
Return the prefix for parameters that mark potentially empty fields.



isBindEmptyMultipartFiles
public boolean isBindEmptyMultipartFiles()(Code)
Return whether to bind empty MultipartFile parameters.



setBindEmptyMultipartFiles
public void setBindEmptyMultipartFiles(boolean bindEmptyMultipartFiles)(Code)
Set whether to bind empty MultipartFile parameters. Default is "true".

Turn this off if you want to keep an already bound MultipartFile when the user resubmits the form without choosing a different file. Else, the already bound MultipartFile will be replaced by an empty MultipartFile holder.
See Also:   org.springframework.web.multipart.MultipartFile




setFieldMarkerPrefix
public void setFieldMarkerPrefix(String fieldMarkerPrefix)(Code)
Specify a prefix that can be used for parameters that mark potentially empty fields, having "prefix + field" as name. Such a marker parameter is checked by existence: You can send any value for it, for example "visible". This is particularly useful for HTML checkboxes and select options.

Default is "_", for "_FIELD" parameters (e.g. "_subscribeToNewsletter"). Set this to null if you want to turn off the empty field check completely.

HTML checkboxes only send a value when they're checked, so it is not possible to detect that a formerly checked box has just been unchecked, at least not with standard HTML means.

One way to address this is to look for a checkbox parameter value if you know that the checkbox has been visible in the form, resetting the checkbox if no value found. In Spring web MVC, this typically happens in a custom onBind implementation.

This auto-reset mechanism addresses this deficiency, provided that a marker parameter is sent for each checkbox field, like "_subscribeToNewsletter" for a "subscribeToNewsletter" field. As the marker parameter is sent in any case, the data binder can detect an empty field and automatically reset its value.
See Also:   WebDataBinder.DEFAULT_FIELD_MARKER_PREFIX
See Also:   org.springframework.web.servlet.mvc.BaseCommandController.onBind




Fields inherited from org.springframework.validation.DataBinder
final public static String DEFAULT_OBJECT_NAME(Code)(Java Doc)
final protected static Log logger(Code)(Java Doc)

Methods inherited from org.springframework.validation.DataBinder
protected void applyPropertyValues(MutablePropertyValues mpvs)(Code)(Java Doc)
public void bind(PropertyValues pvs)(Code)(Java Doc)
protected void checkAllowedFields(MutablePropertyValues mpvs)(Code)(Java Doc)
protected void checkRequiredFields(MutablePropertyValues mpvs)(Code)(Java Doc)
public Map close() throws BindException(Code)(Java Doc)
protected void doBind(MutablePropertyValues mpvs)(Code)(Java Doc)
public PropertyEditor findCustomEditor(Class requiredType, String propertyPath)(Code)(Java Doc)
public String[] getAllowedFields()(Code)(Java Doc)
public BindingErrorProcessor getBindingErrorProcessor()(Code)(Java Doc)
public BindingResult getBindingResult()(Code)(Java Doc)
public String[] getDisallowedFields()(Code)(Java Doc)
public BindException getErrors()(Code)(Java Doc)
protected AbstractPropertyBindingResult getInternalBindingResult()(Code)(Java Doc)
public String getObjectName()(Code)(Java Doc)
protected ConfigurablePropertyAccessor getPropertyAccessor()(Code)(Java Doc)
public String[] getRequiredFields()(Code)(Java Doc)
public Object getTarget()(Code)(Java Doc)
public void initBeanPropertyAccess()(Code)(Java Doc)
public void initDirectFieldAccess()(Code)(Java Doc)
protected boolean isAllowed(String field)(Code)(Java Doc)
public boolean isIgnoreInvalidFields()(Code)(Java Doc)
public boolean isIgnoreUnknownFields()(Code)(Java Doc)
public void registerCustomEditor(Class requiredType, PropertyEditor propertyEditor)(Code)(Java Doc)
public void registerCustomEditor(Class requiredType, String field, PropertyEditor propertyEditor)(Code)(Java Doc)
public void setAllowedFields(String[] allowedFields)(Code)(Java Doc)
public void setBindingErrorProcessor(BindingErrorProcessor bindingErrorProcessor)(Code)(Java Doc)
public void setDisallowedFields(String[] disallowedFields)(Code)(Java Doc)
public void setExtractOldValueForEditor(boolean extractOldValueForEditor)(Code)(Java Doc)
public void setIgnoreInvalidFields(boolean ignoreInvalidFields)(Code)(Java Doc)
public void setIgnoreUnknownFields(boolean ignoreUnknownFields)(Code)(Java Doc)
public void setMessageCodesResolver(MessageCodesResolver messageCodesResolver)(Code)(Java Doc)
public void setRequiredFields(String[] requiredFields)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(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.