Class DefaultDataBinderFactory
- java.lang.Object
- org.springframework.web.bind.support.DefaultDataBinderFactory
- All Implemented Interfaces:
WebDataBinderFactory
- Direct Known Subclasses:
InitBinderDataBinderFactory
public class DefaultDataBinderFactory extends Object implements WebDataBinderFactory
Create aWebRequestDataBinder
instance and initialize it with aWebBindingInitializer
.- Since:
- 3.1
- Author:
- Rossen Stoyanchev
Constructor Summary
Constructors Constructor Description DefaultDataBinderFactory(WebBindingInitializer initializer)
Create a newDefaultDataBinderFactory
instance.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WebDataBinder
createBinder(NativeWebRequest webRequest, Object target, String objectName)
Create a newWebDataBinder
for the given target object and initialize it through aWebBindingInitializer
.protected WebDataBinder
createBinderInstance(Object target, String objectName, NativeWebRequest webRequest)
Extension point to create the WebDataBinder instance.protected void
initBinder(WebDataBinder dataBinder, NativeWebRequest webRequest)
Extension point to further initialize the created data binder instance (e.g.
Constructor Detail
DefaultDataBinderFactory
public DefaultDataBinderFactory(WebBindingInitializer initializer)
Create a newDefaultDataBinderFactory
instance.- Parameters:
initializer
- for global data binder initialization (ornull
if none)
Method Detail
createBinder
public final WebDataBinder createBinder(NativeWebRequest webRequest, Object target, String objectName) throws Exception
Create a newWebDataBinder
for the given target object and initialize it through aWebBindingInitializer
.- Specified by:
createBinder
in interfaceWebDataBinderFactory
- Parameters:
webRequest
- the current requesttarget
- the object to create a data binder for, ornull
if creating a binder for a simple typeobjectName
- the name of the target object- Returns:
- the created
WebDataBinder
instance, never null - Throws:
Exception
- in case of invalid state or arguments
createBinderInstance
protected WebDataBinder createBinderInstance(Object target, String objectName, NativeWebRequest webRequest) throws Exception
Extension point to create the WebDataBinder instance. By default this isWebRequestDataBinder
.- Parameters:
target
- the binding target ornull
for type conversion onlyobjectName
- the binding target object namewebRequest
- the current request- Throws:
Exception
- in case of invalid state or arguments
initBinder
protected void initBinder(WebDataBinder dataBinder, NativeWebRequest webRequest) throws Exception
Extension point to further initialize the created data binder instance (e.g. with@InitBinder
methods) after "global" initializaton viaWebBindingInitializer
.- Parameters:
dataBinder
- the data binder instance to customizewebRequest
- the current request- Throws:
Exception
- if initialization fails