Class AbstractPropertyBindingResult

All Implemented Interfaces:
Serializable, BindingResult, Errors
Direct Known Subclasses:
BeanPropertyBindingResult, DirectFieldBindingResult

public abstract class AbstractPropertyBindingResult extends AbstractBindingResult
Abstract base class for BindingResult implementations that work with Spring's PropertyAccessor mechanism. Pre-implements field access through delegation to the corresponding PropertyAccessor methods.
Since:
2.0
Author:
Juergen Hoeller
See Also:
  • Constructor Details

    • AbstractPropertyBindingResult

      protected AbstractPropertyBindingResult(String objectName)
      Create a new AbstractPropertyBindingResult instance.
      Parameters:
      objectName - the name of the target object
      See Also:
  • Method Details

    • initConversion

      public void initConversion(org.springframework.core.convert.ConversionService conversionService)
    • getPropertyEditorRegistry

      @Nullable public org.springframework.beans.PropertyEditorRegistry getPropertyEditorRegistry()
      Returns the underlying PropertyAccessor.
      Specified by:
      getPropertyEditorRegistry in interface BindingResult
      Overrides:
      getPropertyEditorRegistry in class AbstractBindingResult
      Returns:
      the PropertyEditorRegistry, or null if none available for this BindingResult
      See Also:
    • canonicalFieldName

      protected String canonicalFieldName(String field)
      Returns the canonical property name.
      Overrides:
      canonicalFieldName in class AbstractErrors
      Parameters:
      field - the original field name
      Returns:
      the canonical field name
      See Also:
      • PropertyAccessorUtils.canonicalPropertyName(java.lang.String)
    • getFieldType

      @Nullable public Class<?> getFieldType(@Nullable String field)
      Determines the field type from the property type.
      Specified by:
      getFieldType in interface Errors
      Overrides:
      getFieldType in class AbstractBindingResult
      Parameters:
      field - the field name
      Returns:
      the type of the field, or null if not determinable
      See Also:
    • getActualFieldValue

      @Nullable protected Object getActualFieldValue(String field)
      Fetches the field value from the PropertyAccessor.
      Specified by:
      getActualFieldValue in class AbstractBindingResult
      Parameters:
      field - the field to check
      Returns:
      the current value of the field
      See Also:
    • formatFieldValue

      @Nullable protected Object formatFieldValue(String field, @Nullable Object value)
      Formats the field value based on registered PropertyEditors.
      Overrides:
      formatFieldValue in class AbstractBindingResult
      Parameters:
      field - the field to check
      value - the value of the field (either a rejected value other than from a binding error, or an actual field value)
      Returns:
      the formatted value
      See Also:
    • getCustomEditor

      @Nullable protected PropertyEditor getCustomEditor(String fixedField)
      Retrieve the custom PropertyEditor for the given field, if any.
      Parameters:
      fixedField - the fully qualified field name
      Returns:
      the custom PropertyEditor, or null
    • findEditor

      @Nullable public PropertyEditor findEditor(@Nullable String field, @Nullable Class<?> valueType)
      This implementation exposes a PropertyEditor adapter for a Formatter, if applicable.
      Specified by:
      findEditor in interface BindingResult
      Overrides:
      findEditor in class AbstractBindingResult
      Parameters:
      field - the path of the property (name or nested path), or null if looking for an editor for all properties of the given type
      valueType - the type of the property (can be null if a property is given but should be specified in any case for consistency checking)
      Returns:
      the registered editor, or null if none
    • getPropertyAccessor

      public abstract org.springframework.beans.ConfigurablePropertyAccessor getPropertyAccessor()
      Provide the PropertyAccessor to work with, according to the concrete strategy of access.

      Note that a PropertyAccessor used by a BindingResult should always have its "extractOldValueForEditor" flag set to "true" by default, since this is typically possible without side effects for model objects that serve as data binding target.

      See Also:
      • ConfigurablePropertyAccessor.setExtractOldValueForEditor(boolean)