org.springframework.validation.BindingResult |
Known Indirect Subclasses |
General interface that represents binding results. Extends the
interface
for error registration capabilities,
allowing for a Validator
to be applied, and adds
binding-specific analysis and model building.
Serves as result holder for a DataBinder
, obtained via
the getBindingResult()
method. BindingResult
implementations can also be used directly, for example to invoke
a Validator
on it (e.g. as part of a unit test).
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
org.springframework.validation.Errors
|
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MODEL_KEY_PREFIX | Prefix for the name of the BindingResult instance in a model, followed by the object name. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add a custom
ObjectError or FieldError to the errors list. | |||||||||||
Find a custom property editor for the given type and property.
| |||||||||||
Return a model Map for the obtained state, exposing a BindingResult
instance as '
MODEL_KEY_PREFIX + objectName'
and the object itself as 'objectName'. | |||||||||||
Return the underlying PropertyEditorRegistry.
| |||||||||||
Extract the raw field value for the given field.
| |||||||||||
Return the list of fields that were suppressed during the bind process.
| |||||||||||
Return the wrapped target object, which may be a bean, an object with
public fields, a Map - depending on the concrete binding strategy.
| |||||||||||
Mark the specified disallowed field as suppressed.
| |||||||||||
Resolve the given error code into message codes for the given field.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
org.springframework.validation.Errors
|
Prefix for the name of the BindingResult instance in a model, followed by the object name.
Add a custom ObjectError
or FieldError
to the errors list.
Intended to be used by cooperating strategies such as BindingErrorProcessor
.
Find a custom property editor for the given type and property.
field | the path of the property (name or nested path), or
null if looking for an editor for all properties of the given type |
---|---|
valueType | the type of the property (can be null if a property
is given but should be specified in any case for consistency checking) |
null
if none
Return a model Map for the obtained state, exposing a BindingResult
instance as 'MODEL_KEY_PREFIX
+ objectName'
and the object itself as 'objectName'.
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 in a JSP,
which needs access to the BindingResult instance. Spring's pre-built
form controllers will do this for you when rendering a form view.
When building the ModelAndView instance yourself, you need to include
the attributes from the model Map returned by this method.
Return the underlying PropertyEditorRegistry.
null
if none
available for this BindingResult
Extract the raw field value for the given field. Typically used for comparison purposes.
field | the field to check |
---|
null
if not known
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.
Return the wrapped target object, which may be a bean, an object with public fields, a Map - depending on the concrete binding strategy.
Mark the specified disallowed field as suppressed.
The data binder invokes this for each field value that was detected to target a disallowed field.
Resolve the given error code into message codes for the given field.
Calls the configured MessageCodesResolver
with appropriate parameters.
errorCode | the error code to resolve into message codes |
---|---|
field | the field to resolve message codes for |