Package org.springframework.validation

# Class DirectFieldBindingResult

java.lang.Object
org.springframework.validation.AbstractErrors
org.springframework.validation.AbstractBindingResult
org.springframework.validation.AbstractPropertyBindingResult
org.springframework.validation.DirectFieldBindingResult

All Implemented Interfaces:
  `Serializable`, `BindingResult`, `Errors`

public class DirectFieldBindingResult extends AbstractPropertyBindingResult
Special implementation of the Errors and BindingResult interfaces, supporting registration and evaluation of binding errors on value objects. Performs direct field access instead of going through JavaBean getters.

Since Spring 4.1 this implementation is able to traverse nested fields.

Since:
  2.0
Author:
  Juergen Hoeller
See Also:
  - `DataBinder.getBindingResult()`
  - `DataBinder.initDirectFieldAccess()`
  - `BeanPropertyBindingResult`
  - Serialized Form

## Field Summary

### Fields inherited from interface org.springframework.validation.BindingResult

`MODEL_KEY_PREFIX`

### Fields inherited from interface org.springframework.validation.Errors

`NESTED_PATH_SEPARATOR`

## Constructor Summary

Constructors
Constructor
Description
`DirectFieldBindingResult(Object target, String objectName)`
Create a new `DirectFieldBindingResult` for the given target.
`DirectFieldBindingResult(Object target, String objectName, boolean autoGrowNestedPaths)`
Create a new `DirectFieldBindingResult` for the given target.

## Method Summary

Modifier and Type
Method
Description
`protected org.springframework.beans.ConfigurablePropertyAccessor`
`createDirectFieldAccessor()`
Create a new DirectFieldAccessor for the underlying target object.
`final org.springframework.beans.ConfigurablePropertyAccessor`
`getPropertyAccessor()`
Returns the DirectFieldAccessor that this instance uses.
`final Object`
`getTarget()`
Return the wrapped target object.

### Methods inherited from class org.springframework.validation.AbstractPropertyBindingResult

`canonicalFieldName, findEditor, formatFieldValue, getActualFieldValue, getCustomEditor, getFieldType, getPropertyEditorRegistry, initConversion`

### Methods inherited from class org.springframework.validation.AbstractBindingResult

`addAllErrors, addError, equals, getAllErrors, getErrorCount, getFieldError, getFieldError, getFieldErrors, getFieldErrors, getFieldValue, getGlobalError, getGlobalErrors, getMessageCodesResolver, getModel, getObjectName, getRawFieldValue, getSuppressedFields, hasErrors, hashCode, recordFieldValue, recordSuppressedField, reject, rejectValue, resolveMessageCodes, resolveMessageCodes, setMessageCodesResolver`

### Methods inherited from class org.springframework.validation.AbstractErrors

`doSetNestedPath, fixedField, getNestedPath, isMatchingFieldError, popNestedPath, pushNestedPath, setNestedPath, toString`

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

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.springframework.validation.Errors

`failOnError, getFieldErrorCount, getFieldErrorCount, getGlobalErrorCount, getNestedPath, hasFieldErrors, hasFieldErrors, hasGlobalErrors, popNestedPath, pushNestedPath, reject, reject, rejectValue, rejectValue, setNestedPath, toString`

## Constructor Details

### DirectFieldBindingResult

public DirectFieldBindingResult(@Nullable Object target, String objectName)
Create a new `DirectFieldBindingResult` for the given target.

Parameters:
  `target` - the target object to bind onto
  `objectName` - the name of the target object

### DirectFieldBindingResult

public DirectFieldBindingResult(@Nullable Object target, String objectName, boolean autoGrowNestedPaths)
Create a new `DirectFieldBindingResult` for the given target.

Parameters:
  `target` - the target object to bind onto
  `objectName` - the name of the target object
  `autoGrowNestedPaths` - whether to "auto-grow" a nested path that contains a null value

## Method Details

### getTarget

@Nullable public final Object getTarget()
Description copied from class: `AbstractBindingResult`
Return the wrapped target object.

Specified by:
  `getTarget` in interface `BindingResult`
Specified by:
  `getTarget` in class `AbstractBindingResult`

### getPropertyAccessor

public final org.springframework.beans.ConfigurablePropertyAccessor getPropertyAccessor()
Returns the DirectFieldAccessor that this instance uses. Creates a new one if none existed before.

Specified by:
  `getPropertyAccessor` in class `AbstractPropertyBindingResult`
See Also:
  - `createDirectFieldAccessor()`

### createDirectFieldAccessor

protected org.springframework.beans.ConfigurablePropertyAccessor createDirectFieldAccessor()
Create a new DirectFieldAccessor for the underlying target object.

See Also:
  - `getTarget()`