The Spring Framework

org.springframework.validation
Class AbstractPropertyBindingResult

java.lang.Object
  extended by org.springframework.validation.AbstractBindingResult
      extended by org.springframework.validation.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:
getPropertyAccessor(), PropertyAccessor, ConfigurablePropertyAccessor, 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
protected AbstractPropertyBindingResult(String objectName)
          Create a new AbstractPropertyBindingResult instance.
 
Method Summary
protected  String canonicalFieldName(String field)
          Returns the canonical property name.
protected  Object formatFieldValue(String field, Object value)
          Formats the field value based on registered PropertyEditors.
 Object getActualFieldValue(String field)
          Fetches the field value from the PropertyAccessor.
 PropertyEditor getCustomEditor(String field)
          Retrieve the custom PropertyEditor for the given field, if any.
 Class getFieldType(String field)
          Determines the field type from the property type.
abstract  ConfigurablePropertyAccessor getPropertyAccessor()
          Provide the PropertyAccessor to work with, according to the concrete strategy of access.
 PropertyEditorRegistry getPropertyEditorRegistry()
          Returns the underlying PropertyAccessor.
 
Methods inherited from class org.springframework.validation.AbstractBindingResult
addAllErrors, addError, doSetNestedPath, equals, fixedField, getAllErrors, getErrorCount, getFieldError, getFieldError, getFieldErrorCount, getFieldErrorCount, getFieldErrors, getFieldErrors, getFieldValue, getGlobalError, getGlobalErrorCount, getGlobalErrors, getMessageCodesResolver, getModel, getNestedPath, getObjectName, getSuppressedFields, getTarget, hasErrors, hasFieldErrors, hasFieldErrors, hasGlobalErrors, hashCode, isMatchingFieldError, popNestedPath, pushNestedPath, recordSuppressedField, reject, reject, reject, rejectValue, rejectValue, rejectValue, resolveMessageCodes, resolveMessageCodes, setMessageCodesResolver, setNestedPath, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractPropertyBindingResult

protected AbstractPropertyBindingResult(String objectName)
Create a new AbstractPropertyBindingResult instance.

Parameters:
objectName - the name of the target object
See Also:
DefaultMessageCodesResolver
Method Detail

getPropertyEditorRegistry

public PropertyEditorRegistry getPropertyEditorRegistry()
Returns the underlying PropertyAccessor.

Specified by:
getPropertyEditorRegistry in interface BindingResult
Overrides:
getPropertyEditorRegistry in class AbstractBindingResult
See Also:
getPropertyAccessor()

canonicalFieldName

protected String canonicalFieldName(String field)
Returns the canonical property name.

Overrides:
canonicalFieldName in class AbstractBindingResult
Parameters:
field - the original field name
Returns:
the canonical field name
See Also:
PropertyAccessorUtils.canonicalPropertyName(java.lang.String)

getFieldType

public Class getFieldType(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:
getPropertyAccessor()

getActualFieldValue

public 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:
getPropertyAccessor()

formatFieldValue

protected Object formatFieldValue(String field,
                                  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(java.lang.String)

getCustomEditor

public PropertyEditor getCustomEditor(String field)
Retrieve the custom PropertyEditor for the given field, if any.

Parameters:
field - the field name
Returns:
the custom PropertyEditor, or null

getPropertyAccessor

public abstract 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)

The Spring Framework

Copyright © 2002-2007 The Spring Framework.