Package org.appng.api
Class FormDataBinder<T>
- java.lang.Object
-
- org.springframework.validation.DataBinder
-
- org.appng.api.RequestDataBinder<T>
-
- org.appng.api.FormDataBinder<T>
-
- Type Parameters:
T
- The type to bind the data to.
- All Implemented Interfaces:
org.springframework.beans.PropertyEditorRegistry
,org.springframework.beans.TypeConverter
public class FormDataBinder<T> extends RequestDataBinder<T>
ADataBinder
that uses aForm
to bind its values to the target object. Additional parameters that are not part of the form can also be used usingsetBindAdditionalParams(boolean)
. Also, some additional properties can be used by callingsetExternalParams(Map)
.
This class is especially useful inside aFormProcessProvider
, as shown below:public void onFormSuccess(Environment environment, Site site, Application application, Writer writer, Form form, Map
Also 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.- Author:
- Matthias Müller
-
-
Constructor Summary
Constructors Constructor Description FormDataBinder(T target, Form form)
Constructs a newFormDataBinder
using aDefaultConversionService
FormDataBinder(T target, Form form, org.springframework.core.convert.ConversionService conversionService)
* Constructs a newFormDataBinder
using the givenConversionService
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 aFormElement
of the givenForm
void
setExternalParams(Map<String,Object> externalParams)
Sets some additional external parameters used for binding-
Methods inherited from class org.appng.api.RequestDataBinder
addValue
-
Methods inherited from class org.springframework.validation.DataBinder
addCustomFormatter, addCustomFormatter, addCustomFormatter, addValidators, applyPropertyValues, bind, checkAllowedFields, checkRequiredFields, close, convertIfNecessary, 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, setIgnoreInvalidFields, setIgnoreUnknownFields, setMessageCodesResolver, setRequiredFields, setValidator, validate, validate
-
-
-
-
Constructor Detail
-
FormDataBinder
public FormDataBinder(T target, Form form)
Constructs a newFormDataBinder
using aDefaultConversionService
- Parameters:
target
- the target objectform
- theForm
-
FormDataBinder
public FormDataBinder(T target, Form form, org.springframework.core.convert.ConversionService conversionService)
* Constructs a newFormDataBinder
using the givenConversionService
- Parameters:
target
- the target objectform
- theForm
conversionService
- theConversionService
to use
-
-
Method Detail
-
bind
public T bind()
Performs the actual binding. Therefore, allFormElement
s are retrieved from theForm
. Also, additional and external parameters might be used.- Overrides:
bind
in classRequestDataBinder<T>
- Returns:
- the object where the binding has been applied to
- See Also:
setBindAdditionalParams(boolean)
,setExternalParams(Map)
-
isBindAdditionalParams
public boolean isBindAdditionalParams()
-
setBindAdditionalParams
public void setBindAdditionalParams(boolean bindAdditionalParams)
Whether to use all request parameters for binding, including those that are not defined through aFormElement
of the givenForm
- Parameters:
bindAdditionalParams
- whether to use all request parameters for binding
-
setExternalParams
public void setExternalParams(Map<String,Object> externalParams)
Sets some additional external parameters used for binding- Parameters:
externalParams
- the external parameters
-
-