BindingResult interface (and its super-interface Errors)
to allow for the direct analysis of binding errors.
As of Spring 2.0, this is a special-purpose class. Normally,
application code will work with the BindingResult interface,
or with a DataBinder that in turn exposes a BindingResult via
org..
BindingResult, DataBinder#getBindingResult(), DataBinder#close()
| Modifier and Type | Field and Description |
|---|---|
| private final BindingResult |
| Access | Constructor and Description |
|---|---|
| public | BindException(BindingResult
the BindingResult instance to wrap bindingResult)Create a new BindException instance for a BindingResult. |
| public | BindException(Object
the target bean to bind onto target, String the name of the target object objectName)Create a new BindException instance for a target bean. |
| Modifier and Type | Method and Description |
|---|---|
| public void | addAllErrors(Errors
the errors)Errors instance to merge inOverrides default org. Errors instance to this
Errors instance.
|
| public void | addError(ObjectError error)
Implements org. ObjectError or FieldError to the errors list.
|
| public boolean | equals(Object
the reference object with which to compare. other)Overrides java. |
| public PropertyEditor | findEditor(String
the path of the property (name or nested path), or
field, Class<T> null if looking for an editor for all properties of the given typethe type of the property (can be valueType)null if a property
is given but should be specified in any case for consistency checking)Implements org. |
| public List | getAllErrors()
Overrides default org. |
| public final BindingResult | |
| public int | getErrorCount()
Overrides default org. |
| public FieldError | getFieldError()
Overrides default org. |
| public FieldError | getFieldError(String
the field name field)Overrides default org. |
| public int | getFieldErrorCount()
Overrides default org. |
| public int | getFieldErrorCount(String
the field name field)Overrides default org. |
| public List | getFieldErrors()
Implements org. |
| public List | getFieldErrors(String
the field name field)Overrides default org. |
| public Class | getFieldType(String
the field name field)Overrides default org. |
| public Object | getFieldValue(String
the field name field)Implements org. |
| public ObjectError | getGlobalError()
Overrides default org. |
| public int | getGlobalErrorCount()
Overrides default org. |
| public List | getGlobalErrors()
Implements org. |
| public String | getMessage()
Overrides java. |
| public Map | getModel()
Implements org. MODEL_KEY_PREFIX + objectName'
and the object itself as 'objectName'.
|
| public String | getNestedPath()
Overrides default org. Errors object.
|
| public String | getObjectName()
Implements org. |
| public PropertyEditorRegistry | getPropertyEditorRegistry()
Implements org. |
| public Object | getRawFieldValue(String
the field to check field)Implements org. |
| public String[] | getSuppressedFields()
Overrides default org. |
| public Object | getTarget()
Implements org. |
| public boolean | hasErrors()
Overrides default org. |
| public boolean | hasFieldErrors()
Overrides default org. |
| public boolean | hasFieldErrors(String
the field name field)Overrides default org. |
| public boolean | hasGlobalErrors()
Overrides default org. |
| public int | |
| public void | popNestedPath()
Overrides default org. |
| public void | pushNestedPath(String
the sub path to push onto the nested path stack subPath)Overrides default org. |
| public void | recordFieldValue(String
the field to record the value for field, Class<?> the type of the field type, Object the original value value)Overrides default org. |
| public void | recordSuppressedField(String field)
Overrides default org. |
| public void | reject(String
error code, interpretable as a message key errorCode)Overrides default org. |
| public void | reject(String
error code, interpretable as a message key errorCode, String fallback default message defaultMessage)Overrides default org. |
| public void | reject(String
error code, interpretable as a message key errorCode, Object[] error arguments, for argument binding via MessageFormat
(can be errorArgs, String null)fallback default message defaultMessage)Implements org. |
| public void | rejectValue(String
the field name (may be field, String null or empty String)error code, interpretable as a message key errorCode)Overrides default org. |
| public void | rejectValue(String
the field name (may be field, String null or empty String)error code, interpretable as a message key errorCode, String fallback default message defaultMessage)Overrides default org. |
| public void | rejectValue(String
the field name (may be field, String null or empty String)error code, interpretable as a message key errorCode, Object[] error arguments, for argument binding via MessageFormat
(can be errorArgs, String null)fallback default message defaultMessage)Implements org. |
| public String[] | resolveMessageCodes(String
the error code to resolve into message codes errorCode)Implements org. |
| public String[] | resolveMessageCodes(String
the error code to resolve into message codes errorCode, String the field to resolve message codes for field)Implements org. |
| public void | setNestedPath(String
nested path within this object,
e.g. "address" (defaults to "", nestedPath)null is also acceptable).
Can end with a dot: both "address" and "address." are valid.Overrides default org. |
| bindingResult | back to summary |
|---|---|
| private final BindingResult bindingResult | |
| BindException | back to summary |
|---|---|
| public BindException(BindingResult bindingResult) Create a new BindException instance for a BindingResult.
| |
| BindException | back to summary |
|---|---|
| public BindException(Object target, String objectName) Create a new BindException instance for a target bean.
| |
| addAllErrors | back to summary |
|---|---|
| public void addAllErrors(Errors errors) Overrides default org. Doc from org. Add all errors from the given This is a convenience method to avoid repeated Note that the passed-in The default implementation throws | |
| addError | back to summary |
|---|---|
| public void addError(ObjectError error) Implements org. Doc from org. Add a custom Intended to be used by cooperating strategies such as
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| findEditor | back to summary |
|---|---|
| public PropertyEditor findEditor(String field, Class<T> valueType) Implements org. Doc from org. Find a custom property editor for the given type and property.
| |
| getAllErrors | back to summary |
|---|---|
| public List Overrides default org. Doc from org. Get all errors, both global and field ones.
| |
| getBindingResult | back to summary |
|---|---|
| public final BindingResult getBindingResult() Return the BindingResult that this BindException wraps. | |
| getErrorCount | back to summary |
|---|---|
| public int getErrorCount() Overrides default org. Doc from org. Determine the total number of errors.
| |
| getFieldError | back to summary |
|---|---|
| public FieldError getFieldError() Overrides default org. Doc from org. Get the first error associated with a field, if any.
| |
| getFieldError | back to summary |
|---|---|
| public FieldError getFieldError(String field) Overrides default org. Doc from org. Get the first error associated with the given field, if any.
| |
| getFieldErrorCount | back to summary |
|---|---|
| public int getFieldErrorCount() Overrides default org. Doc from org. Determine the number of errors associated with a field.
| |
| getFieldErrorCount | back to summary |
|---|---|
| public int getFieldErrorCount(String field) Overrides default org. Doc from org. Determine the number of errors associated with the given field. | |
| getFieldErrors | back to summary |
|---|---|
| public List Implements org. Doc from org. Get all errors associated with a field.
| |
| getFieldErrors | back to summary |
|---|---|
| public List Overrides default org. Doc from org. Get all errors associated with the given field. Implementations may support not only full field names like "address.street" but also pattern matches like "address.*".
| |
| getFieldType | back to summary |
|---|---|
| public Class Overrides default org. Doc from org. Determine the type of the given field, as far as possible. Implementations should be able to determine the type even
when the field value is | |
| getFieldValue | back to summary |
|---|---|
| public Object getFieldValue(String field) Implements org. Doc from org. Return the current value of the given field, either the current bean property value or a rejected update from the last binding. Allows for convenient access to user-specified field values, even if there were type mismatches. | |
| getGlobalError | back to summary |
|---|---|
| public ObjectError getGlobalError() Overrides default org. Doc from org. Get the first global error, if any.
| |
| getGlobalErrorCount | back to summary |
|---|---|
| public int getGlobalErrorCount() Overrides default org. Doc from org. Determine the number of global errors.
| |
| getGlobalErrors | back to summary |
|---|---|
| public List Implements org. Doc from org. Get all global errors.
| |
| getMessage | back to summary |
|---|---|
| public String getMessage() Overrides java. Returns diagnostic information about the errors held in this object.
| |
| getModel | back to summary |
|---|---|
| public Map Implements org. Doc from org. Return a model Map for the obtained state, exposing a BindingResult
instance as ' Note that the Map is constructed every time you're calling this method. Adding things to the map and then re-calling this method will not work. The attributes in the model Map returned by this method are usually
included in the
| |
| getNestedPath | back to summary |
|---|---|
| public String getNestedPath() Overrides default org. Doc from org. Return the current nested path of this Returns a nested path with a dot, i.e. "address.", for easy building of concatenated paths. Default is an empty String.
| |
| getObjectName | back to summary |
|---|---|
| public String getObjectName() Implements org. Doc from org. Return the name of the bound root object.
| |
| getPropertyEditorRegistry | back to summary |
|---|---|
| public PropertyEditorRegistry getPropertyEditorRegistry() Implements org. Doc from org. Return the underlying PropertyEditorRegistry.
| |
| getRawFieldValue | back to summary |
|---|---|
| public Object getRawFieldValue(String field) Implements org. Doc from org. Extract the raw field value for the given field. Typically used for comparison purposes. | |
| getSuppressedFields | back to summary |
|---|---|
| public String[] getSuppressedFields() Overrides default org. Doc from org. Return the list of fields that were suppressed during the bind process. Can be used to determine whether any field values were targeting disallowed fields.
| |
| getTarget | back to summary |
|---|---|
| public Object getTarget() Implements org. Doc from org. Return the wrapped target object, which may be a bean, an object with public fields, a Map - depending on the concrete binding strategy. | |
| hasErrors | back to summary |
|---|---|
| public boolean hasErrors() Overrides default org. Doc from org. Determine if there were any errors.
| |
| hasFieldErrors | back to summary |
|---|---|
| public boolean hasFieldErrors() Overrides default org. Doc from org. Determine if there were any errors associated with a field.
| |
| hasFieldErrors | back to summary |
|---|---|
| public boolean hasFieldErrors(String field) Overrides default org. Doc from org. Determine if there were any errors associated with the given field. | |
| hasGlobalErrors | back to summary |
|---|---|
| public boolean hasGlobalErrors() Overrides default org. Doc from org. Determine if there were any global errors.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| popNestedPath | back to summary |
|---|---|
| public void popNestedPath() throws IllegalStateException Overrides default org. Doc from org. Pop the former nested path from the nested path stack.
| |
| pushNestedPath | back to summary |
|---|---|
| public void pushNestedPath(String subPath) Overrides default org. Doc from org. Push the given sub path onto the nested path stack. A Using the nested path stack allows to set temporary nested paths for subobjects without having to worry about a temporary path holder. For example: current path "spouse.", pushNestedPath("child") → result path "spouse.child."; popNestedPath() → "spouse." again. The default implementation throws | |
| recordFieldValue | back to summary |
|---|---|
| public void recordFieldValue(String field, Class<?> type, Object value) Overrides default org. Doc from org. Record the given value for the specified field. To be used when a target object cannot be constructed, making
the original field values available through | |
| recordSuppressedField | back to summary |
|---|---|
| public void recordSuppressedField(String field) Overrides default org. Doc from org. Mark the specified disallowed field as suppressed. The data binder invokes this for each field value that was detected to target a disallowed field.
| |
| reject | back to summary |
|---|---|
| public void reject(String errorCode) Overrides default org. Doc from org. Register a global error for the entire target object, using the given error description. | |
| reject | back to summary |
|---|---|
| public void reject(String errorCode, String defaultMessage) Overrides default org. Doc from org. Register a global error for the entire target object, using the given error description. | |
| reject | back to summary |
|---|---|
| public void reject(String errorCode, Object[] errorArgs, String defaultMessage) Implements org. Doc from org. Register a global error for the entire target object, using the given error description. | |
| rejectValue | back to summary |
|---|---|
| public void rejectValue(String field, String errorCode) Overrides default org. Doc from org. Register a field error for the specified field of the current object (respecting the current nested path, if any), using the given error description. The field name may be | |
| rejectValue | back to summary |
|---|---|
| public void rejectValue(String field, String errorCode, String defaultMessage) Overrides default org. Doc from org. Register a field error for the specified field of the current object (respecting the current nested path, if any), using the given error description. The field name may be | |
| rejectValue | back to summary |
|---|---|
| public void rejectValue(String field, String errorCode, Object[] errorArgs, String defaultMessage) Implements org. Doc from org. Register a field error for the specified field of the current object (respecting the current nested path, if any), using the given error description. The field name may be | |
| resolveMessageCodes | back to summary |
|---|---|
| public String[] resolveMessageCodes(String errorCode) Implements org. Doc from org. Resolve the given error code into message codes. Calls the configured | |
| resolveMessageCodes | back to summary |
|---|---|
| public String[] resolveMessageCodes(String errorCode, String field) Implements org. Doc from org. Resolve the given error code into message codes for the given field. Calls the configured | |
| setNestedPath | back to summary |
|---|---|
| public void setNestedPath(String nestedPath) Overrides default org. Doc from org. Allow context to be changed so that standard validators can validate subtrees. Reject calls prepend the given path to the field names. For example, an address validator could validate the subobject "address" of a customer object. The default implementation throws | |