com.interface21.validation
Class DataBinder
java.lang.Object
|
+--java.lang.Throwable
|
+--java.lang.Exception
|
+--com.interface21.validation.BindException
|
+--com.interface21.validation.DataBinder
- All Implemented Interfaces:
- Errors, java.io.Serializable
- Direct Known Subclasses:
- ServletRequestDataBinder
- public class DataBinder
- extends BindException
Binder that allows for binding property values to a target object.
Slightly unusual, as it _is_ an exception.
Supports property change listeners and vetoable change listeners.
- Version:
- 1.0
- Author:
- Rod Johnson
- See Also:
- Serialized Form
|
Constructor Summary |
DataBinder(java.lang.Object target,
java.lang.String objName)
|
|
Method Summary |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
|
void |
addVetoableChangeListener(java.beans.VetoableChangeListener vcl)
|
void |
bind(PropertyValues pvs)
Bind the given property values to this binder's target.
|
java.util.Map |
close()
Close this DataBinder, which may result in throwing
a BindException if it encountered any errors |
java.lang.Object |
getFieldValue(java.lang.String field)
Render the field value with a custom editor, if applicable. |
protected java.lang.String[] |
getRequiredFields()
|
void |
registerCustomEditor(java.lang.Class requiredType,
java.beans.PropertyEditor propertyEditor)
Register the given custom property editor for all properties
of the given type. |
void |
registerCustomEditor(java.lang.Class requiredType,
java.lang.String field,
java.beans.PropertyEditor propertyEditor)
Register the given custom property editor for the given type and
field, or for all fields of the given type. |
void |
setRequiredFields(java.lang.String[] requiredFields)
|
| Methods inherited from class com.interface21.validation.BindException |
addFieldError, getAllErrors, getBeanWrapper, getErrorCount, getFieldError, getFieldErrorCount, getFieldErrors, getGlobalError, getGlobalErrorCount, getGlobalErrors, getMessage, getModel, getObjectName, getTarget, hasErrors, hasFieldErrors, hasGlobalErrors, reject, rejectValue, setNestedPath |
| Methods inherited from class java.lang.Throwable |
fillInStackTrace, getLocalizedMessage, printStackTrace, printStackTrace, printStackTrace, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
MISSING_FIELD_ERROR_CODE
public static final java.lang.String MISSING_FIELD_ERROR_CODE
logger
protected static final org.apache.commons.logging.Log logger
DataBinder
public DataBinder(java.lang.Object target,
java.lang.String objName)
setRequiredFields
public void setRequiredFields(java.lang.String[] requiredFields)
getRequiredFields
protected java.lang.String[] getRequiredFields()
addVetoableChangeListener
public void addVetoableChangeListener(java.beans.VetoableChangeListener vcl)
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
registerCustomEditor
public void registerCustomEditor(java.lang.Class requiredType,
java.lang.String field,
java.beans.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 checkingfield - name of the field (can also be a nested path), or
null if registering an editor for all fields of the given typepropertyEditor - editor to register
registerCustomEditor
public void registerCustomEditor(java.lang.Class requiredType,
java.beans.PropertyEditor propertyEditor)
- Register the given custom property editor for all properties
of the given type.
- Parameters:
requiredType - type of the propertypropertyEditor - editor to register
getFieldValue
public java.lang.Object getFieldValue(java.lang.String field)
- Render the field value with a custom editor, if applicable.
- Overrides:
getFieldValue in class BindException
- Following copied from interface:
com.interface21.validation.Errors
- Parameters:
field - field name- Returns:
- the current value of the given field
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 java.util.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
Rod Johnson and Spring contributors 2001-2003.