Package org.springframework.web.method.annotation

# Class InitBinderDataBinderFactory

java.lang.Object
org.springframework.web.bind.support.DefaultDataBinderFactory
org.springframework.web.method.annotation.InitBinderDataBinderFactory

All Implemented Interfaces:
  `WebDataBinderFactory`

public class InitBinderDataBinderFactory extends DefaultDataBinderFactory
Adds initialization to a WebDataBinder via `@InitBinder` methods.

Since:
  3.1
Author:
  Rossen Stoyanchev

## Constructor Summary

Constructors
Constructor
Description
`InitBinderDataBinderFactory(List<InvocableHandlerMethod> binderMethods, WebBindingInitializer initializer)`
Create a new InitBinderDataBinderFactory instance.

## Method Summary

Modifier and Type
Method
Description
`void`
`initBinder(WebDataBinder dataBinder, NativeWebRequest request)`
Initialize a WebDataBinder with `@InitBinder` methods.
`protected boolean`
`isBinderMethodApplicable(HandlerMethod initBinderMethod, WebDataBinder dataBinder)`
Determine whether the given `@InitBinder` method should be used to initialize the given `WebDataBinder` instance.

### Methods inherited from class org.springframework.web.bind.support.DefaultDataBinderFactory

`createBinder, createBinder, createBinderInstance, setMethodValidationApplicable`

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

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

## Constructor Details

### InitBinderDataBinderFactory

public InitBinderDataBinderFactory(@Nullable List<InvocableHandlerMethod> binderMethods, @Nullable WebBindingInitializer initializer)
Create a new InitBinderDataBinderFactory instance.

Parameters:
  `binderMethods` - `@InitBinder` methods
  `initializer` - for global data binder initialization

## Method Details

### initBinder

public void initBinder(WebDataBinder dataBinder, NativeWebRequest request) throws Exception
Initialize a WebDataBinder with `@InitBinder` methods.

If the `@InitBinder` annotation specifies attributes names, it is invoked only if the names include the target object name.

Overrides:
  `initBinder` in class `DefaultDataBinderFactory`
Parameters:
  `dataBinder` - the data binder instance to customize
  `request` - the current request
Throws:
  `Exception` - if one of the invoked @`InitBinder` methods fails
See Also:
  - `isBinderMethodApplicable(org.springframework.web.method.HandlerMethod, org.springframework.web.bind.WebDataBinder)`

### isBinderMethodApplicable

protected boolean isBinderMethodApplicable(HandlerMethod initBinderMethod, WebDataBinder dataBinder)
Determine whether the given `@InitBinder` method should be used to initialize the given `WebDataBinder` instance. By default we check the specified attribute names in the annotation value, if any.