T
- The type to bind the data to.public class FormDataBinder<T> extends RequestDataBinder<T>
DataBinder
that uses a Form
to bind its values to the target object. Additional parameters that are
not part of the form can also be used using setBindAdditionalParams(boolean)
. Also, some additional
properties can be used by calling setExternalParams(Map)
.FormProcessProvider
, as shown below:
public void onFormSuccess(Environment environment, Site site, Application application, Writer writer, Form form, MapAlso note the possibility to set a customproperties) { FormDataBinder formDataBinder = new FormDataBinder (new Person(), form); formDataBinder.setExternalParams(properties); Person person = formDataBinder.bind(); // proceed with person }
ConversionService
for the binder.Constructor and Description |
---|
FormDataBinder(T target,
Form form)
Constructs a new
FormDataBinder using a DefaultConversionService |
FormDataBinder(T target,
Form form,
org.springframework.core.convert.ConversionService conversionService)
* Constructs a new
FormDataBinder using the given ConversionService |
Modifier and Type | Method and Description |
---|---|
T |
bind()
Performs the actual binding.
|
Map<String,Object> |
getExternalParams() |
boolean |
isBindAdditionalParams() |
void |
setBindAdditionalParams(boolean bindAdditionalParams)
Whether to use all request parameters for binding, including those that are not defined through a
FormElement of the given Form |
void |
setExternalParams(Map<String,Object> externalParams)
Sets some additional external parameters used for binding
|
addValue
addCustomFormatter, addCustomFormatter, addCustomFormatter, addValidators, applyPropertyValues, bind, checkAllowedFields, checkRequiredFields, close, convertIfNecessary, convertIfNecessary, convertIfNecessary, createBeanPropertyBindingResult, createDirectFieldBindingResult, doBind, findCustomEditor, getAllowedFields, getAutoGrowCollectionLimit, getBindingErrorProcessor, getBindingResult, getConversionService, getDisallowedFields, getInternalBindingResult, getObjectName, getPropertyAccessor, getPropertyEditorRegistry, getRequiredFields, getSimpleTypeConverter, getTarget, getTypeConverter, getValidator, getValidators, initBeanPropertyAccess, initDirectFieldAccess, isAllowed, isAutoGrowNestedPaths, isIgnoreInvalidFields, isIgnoreUnknownFields, registerCustomEditor, registerCustomEditor, replaceValidators, setAllowedFields, setAutoGrowCollectionLimit, setAutoGrowNestedPaths, setBindingErrorProcessor, setConversionService, setDisallowedFields, setExtractOldValueForEditor, setIgnoreInvalidFields, setIgnoreUnknownFields, setMessageCodesResolver, setRequiredFields, setValidator, validate, validate
public FormDataBinder(T target, Form form)
FormDataBinder
using a DefaultConversionService
target
- the target objectform
- the Form
public FormDataBinder(T target, Form form, org.springframework.core.convert.ConversionService conversionService)
FormDataBinder
using the given ConversionService
target
- the target objectform
- the Form
conversionService
- the ConversionService
to usepublic T bind()
FormElement
s are retrieved from the Form
. Also,
additional and external parameters might be used.bind
in class RequestDataBinder<T>
setBindAdditionalParams(boolean)
,
setExternalParams(Map)
public boolean isBindAdditionalParams()
public void setBindAdditionalParams(boolean bindAdditionalParams)
FormElement
of the given Form
bindAdditionalParams
- whether to use all request parameters for bindingpublic void setExternalParams(Map<String,Object> externalParams)
externalParams
- the external parametersCopyright © 2011–2021 aiticon GmbH. All rights reserved.