| java.lang.Object org.springframework.validation.DataBinder org.springframework.web.bind.WebDataBinder
All known Subclasses: org.springframework.web.portlet.bind.PortletRequestDataBinder, org.springframework.web.bind.ServletRequestDataBinder,
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 |
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 |
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) |
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 |
|
|