Package org.springframework.validation
Interface BindingErrorProcessor
- All Known Implementing Classes:
DefaultBindingErrorProcessor
public interface BindingErrorProcessor
Strategy for processing
DataBinder
's missing field errors,
and for translating a PropertyAccessException
to a
FieldError
.
The error processor is pluggable so you can treat errors differently if you want to. A default implementation is provided for typical needs.
Note: As of Spring 2.0, this interface operates on a given BindingResult, to be compatible with any binding strategy (bean property, direct field access, etc). It can still receive a BindException as argument (since a BindException implements the BindingResult interface as well) but no longer operates on it directly.
- Since:
- 1.2
- Author:
- Alef Arendsen, Juergen Hoeller
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
processMissingFieldError
(String missingField, BindingResult bindingResult) Apply the missing field error to the given BindException.void
processPropertyAccessException
(PropertyAccessException ex, BindingResult bindingResult) Translate the givenPropertyAccessException
to an appropriate error registered on the givenErrors
instance.
-
Method Details
-
processMissingFieldError
Apply the missing field error to the given BindException.Usually, a field error is created for a missing required field.
- Parameters:
missingField
- the field that was missing during bindingbindingResult
- the errors object to add the error(s) to. You can add more than just one error or maybe even ignore it. TheBindingResult
object features convenience utils such as aresolveMessageCodes
method to resolve an error code.- See Also:
-
processPropertyAccessException
Translate the givenPropertyAccessException
to an appropriate error registered on the givenErrors
instance.Note that two error types are available:
FieldError
andObjectError
. Usually, field errors are created, but in certain situations one might want to create a globalObjectError
instead.- Parameters:
ex
- thePropertyAccessException
to translatebindingResult
- the errors object to add the error(s) to. You can add more than just one error or maybe even ignore it. TheBindingResult
object features convenience utils such as aresolveMessageCodes
method to resolve an error code.- See Also:
-