org.springframework.validation
Class DataBinder

Direct Known Subclasses:
ServletRequestDataBinder

public class DataBinder

Binder that allows for binding property values to a target object.

Author:
Rod Johnson, Juergen Hoeller
Version: $Id: DataBinder.java,v 1.7 2004/02/02 11:22:54 jhoeller Exp $

Field Summary
 final static StringMISSING_FIELD_ERROR_CODE
           

Constructor Summary
DataBinder(Object target, String name)
          Create a new DataBinder instance.

Method Summary
 voidbind(PropertyValues pvs)
          Bind the given property values to this binder's target.
 Mapclose()
          Close this DataBinder, which may result in throwing a BindException if it encountered any errors
 BindExceptiongetErrors()
          Return the Errors instance for this data binder.
 voidregisterCustomEditor(Class requiredType, PropertyEditor propertyEditor)
          Register the given custom property editor for all properties of the given type.
 voidregisterCustomEditor(Class requiredType, String field, PropertyEditor propertyEditor)
          Register the given custom property editor for the given type and field, or for all fields of the given type.
 voidsetRequiredFields(String[] requiredFields)
          Register fields that are required for each binding process.

Field Detail

MISSING_FIELD_ERROR_CODE

public final static String MISSING_FIELD_ERROR_CODE
Constructor Detail

DataBinder

public DataBinder(Object target, String name)
Create a new DataBinder instance.
Parameters:
target - target object to bind onto
name - name of the target object
Method Detail

bind

public void bind(PropertyValues pvs)
Bind the given property values to this binder's target. This call can create field errors, representing basic binding errors like a required field (code "required"), or type mismatch between value and bean property (code "typeMismatch").
Parameters:
pvs - property values to bind

close

public Map close()
throws BindException
Close this DataBinder, which may result in throwing a BindException if it encountered any errors
Throws:
BindException - if there were any errors in the bind operation

getErrors

public BindException getErrors()
Return the Errors instance for this data binder.
Returns: the Errors instance, to be treated as Errors or as BindException
See Also:
Errors

registerCustomEditor

public void registerCustomEditor(Class requiredType, PropertyEditor propertyEditor)
Register the given custom property editor for all properties of the given type.
Parameters:
requiredType - type of the property
propertyEditor - editor to register

registerCustomEditor

public void registerCustomEditor(Class requiredType, String field, PropertyEditor propertyEditor)
Register the given custom property editor for the given type and field, or for all fields of the given type.
Parameters:
requiredType - type of the property, can be null if a field is given but should be specified in any case for consistency checking
field - name of the field (can also be a nested path), or null if registering an editor for all fields of the given type
propertyEditor - editor to register

setRequiredFields

public void setRequiredFields(String[] requiredFields)
Register fields that are required for each binding process.
Parameters:
requiredFields - array of field names

Association Links

to Class java.lang.String

to Class org.springframework.validation.BindException

to Class java.lang.String