BindingResult interface and
its super-interface Errors. Encapsulates common management of
ObjectErrors and FieldErrors.
Errors
| Modifier and Type | Field and Description |
|---|---|
| private final List | |
| private final Map | |
| private final Map | |
| private MessageCodesResolver | |
| private final String | |
| private final Set |
| Access | Constructor and Description |
|---|---|
| protected | AbstractBindingResult(String
the name of the target object objectName)Create a new AbstractBindingResult instance. |
| 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<?> 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. PropertyEditorRegistry's
editor lookup facility, if available.
|
| protected Object | Returns: the formatted valuethe field to check field, Object the value of the field (either a rejected value
other than from a binding error, or an actual field value) value)Format the given value for the specified field. |
| protected abstract Object | Returns: the current value of the fieldthe field to check field)Extract the actual field value for the given field. |
| public List | getAllErrors()
Overrides default org. |
| public int | getErrorCount()
Overrides default org. |
| public FieldError | getFieldError()
Overrides default org. |
| public FieldError | getFieldError(String
the field name field)Overrides default org. |
| public List | getFieldErrors()
Implements org. |
| public List | getFieldErrors(String
the field name field)Overrides org. 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 List | getGlobalErrors()
Implements org. |
| public MessageCodesResolver | |
| public Map | getModel()
Implements org. MODEL_KEY_PREFIX + objectName'
and the object itself.
|
| public String | getObjectName()
Implements org. |
| public PropertyEditorRegistry | getPropertyEditorRegistry()
Implements org. null.
|
| public Object | getRawFieldValue(String
the field to check field)Implements org. |
| public String[] | getSuppressedFields()
Overrides default org. |
| public abstract Object | getTarget()
Redeclares org. |
| public boolean | hasErrors()
Overrides default org. |
| public int | |
| 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, 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, 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 | setMessageCodesResolver(MessageCodesResolver messageCodesResolver)
Set the strategy to use for resolving errors into message codes. |
| errors | back to summary |
|---|---|
| private final List<ObjectError> errors | |
| fieldTypes | back to summary |
|---|---|
| private final Map<String, Class<?>> fieldTypes | |
| fieldValues | back to summary |
|---|---|
| private final Map<String, Object> fieldValues | |
| messageCodesResolver | back to summary |
|---|---|
| private MessageCodesResolver messageCodesResolver | |
| objectName | back to summary |
|---|---|
| private final String objectName | |
| suppressedFields | back to summary |
|---|---|
| private final Set<String> suppressedFields | |
| AbstractBindingResult | back to summary |
|---|---|
| protected AbstractBindingResult(String objectName) Create a new AbstractBindingResult instance.
| |
| 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<?> valueType) Implements org. This implementation delegates to the
| |
| formatFieldValue | back to summary |
|---|---|
| protected Object formatFieldValue(String field, Object value) Format the given value for the specified field. The default implementation simply returns the field value as-is. | |
| getActualFieldValue | back to summary |
|---|---|
| protected abstract Object getActualFieldValue(String field) Extract the actual field value for the given field. | |
| getAllErrors | back to summary |
|---|---|
| public List Overrides default org. Doc from org. Get all errors, both global and field ones.
| |
| 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.
| |
| 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 org. 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. This default implementation determines the type based on the actual
field value, if any. Subclasses should override this to determine
the type from a descriptor, even for
| |
| 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.
| |
| getGlobalErrors | back to summary |
|---|---|
| public List Implements org. Doc from org. Get all global errors.
| |
| getMessageCodesResolver | back to summary |
|---|---|
| public MessageCodesResolver getMessageCodesResolver() Return the strategy to use for resolving errors into message codes. | |
| getModel | back to summary |
|---|---|
| public Map Implements org. Return a model Map for the obtained state, exposing an Errors
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 ModelAndView for a form view that uses Spring's bind tag, which needs access to the Errors instance.
| |
| 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. This implementation returns
| |
| 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. 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 abstract Object getTarget() Redeclares org. Return the wrapped target object. | |
| hasErrors | back to summary |
|---|---|
| public boolean hasErrors() Overrides default org. Doc from org. Determine if there were any 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
| |
| 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. 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, 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, 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 | |
| setMessageCodesResolver | back to summary |
|---|---|
| public void setMessageCodesResolver(MessageCodesResolver messageCodesResolver) Set the strategy to use for resolving errors into message codes. Default is DefaultMessageCodesResolver.
| |