Package org.springframework.web.bind.support

# 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 a `WebRequestDataBinder` instance and initialize it with a `WebBindingInitializer`.

Since:
  3.1
Author:
  Rossen Stoyanchev

## Constructor Summary

Constructors
Constructor
Description
`DefaultDataBinderFactory(WebBindingInitializer initializer)`
Create a new `DefaultDataBinderFactory` instance.

## Method Summary

Modifier and Type
Method
Description
`final WebDataBinder`
`createBinder(NativeWebRequest webRequest, Object target, String objectName)`
Create a new `WebDataBinder` for the given target object and initialize it through a `WebBindingInitializer`.
`final WebDataBinder`
`createBinder(NativeWebRequest webRequest, Object target, String objectName, org.springframework.core.ResolvableType type)`
Variant of `WebDataBinderFactory.createBinder(NativeWebRequest, Object, String)` with a `ResolvableType` for which the `DataBinder` is created.
`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 (for example, with `@InitBinder` methods) after "global" initialization via `WebBindingInitializer`.
`void`
`setMethodValidationApplicable(boolean methodValidationApplicable)`
Configure flag to signal whether validation will be applied to handler method arguments, which is the case if Bean Validation is enabled in Spring MVC, and method parameters have `@Constraint` annotations.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### DefaultDataBinderFactory

public DefaultDataBinderFactory(@Nullable WebBindingInitializer initializer)
Create a new `DefaultDataBinderFactory` instance.

Parameters:
  `initializer` - for global data binder initialization (or `null` if none)

## Method Details

### setMethodValidationApplicable

public void setMethodValidationApplicable(boolean methodValidationApplicable)
Configure flag to signal whether validation will be applied to handler method arguments, which is the case if Bean Validation is enabled in Spring MVC, and method parameters have `@Constraint` annotations.

Since:
  6.1

### createBinder

public final WebDataBinder createBinder(NativeWebRequest webRequest, @Nullable Object target, String objectName) throws Exception
Create a new `WebDataBinder` for the given target object and initialize it through a `WebBindingInitializer`.

Specified by:
  `createBinder` in interface `WebDataBinderFactory`
Parameters:
  `webRequest` - the current request
  `target` - the object to create a data binder for, or `null` if creating a binder for a simple type
  `objectName` - the name of the target object
Returns:
  the created `WebDataBinder` instance, never null
Throws:
  `Exception` - in case of invalid state or arguments

### createBinder

public final WebDataBinder createBinder(NativeWebRequest webRequest, @Nullable Object target, String objectName, org.springframework.core.ResolvableType type) throws Exception
Variant of `WebDataBinderFactory.createBinder(NativeWebRequest, Object, String)` with a `ResolvableType` for which the `DataBinder` is created. This may be used to construct the target, or otherwise provide more insight on how to initialize the binder.

By default, if the parameter has `@Valid`, Bean Validation is excluded, deferring to method validation.

Specified by:
  `createBinder` in interface `WebDataBinderFactory`
Throws:
  `Exception`

### createBinderInstance

protected WebDataBinder createBinderInstance(@Nullable Object target, String objectName, NativeWebRequest webRequest) throws Exception
Extension point to create the WebDataBinder instance. By default, this is `WebRequestDataBinder`.

Parameters:
  `target` - the binding target or `null` for type conversion only
  `objectName` - the binding target object name
  `webRequest` - 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 (for example, with `@InitBinder` methods) after "global" initialization via `WebBindingInitializer`.

Parameters:
  `dataBinder` - the data binder instance to customize
  `webRequest` - the current request
Throws:
  `Exception` - if initialization fails