org.springframework.validation
Class FieldError
java.lang.Object
org.springframework.context.support.DefaultMessageSourceResolvable
org.springframework.validation.ObjectError
org.springframework.validation.FieldError
- All Implemented Interfaces:
- MessageSourceResolvable, java.io.Serializable
- public class FieldError
- extends ObjectError
Encapsulates a field error, i.e. a reason for rejecting a
specific field value.
A field error gets created with a single code but uses
3 codes for message resolution, in the following order:
- first: code + "." + object name + "." + field;
- then: code + "." + field;
- finally: code.
E.g.: code "typeMismatch", field "age", object name "user":
- 1. try "typeMismatch.user.age";
- 2. try "typeMismatch.age";
- 3. try "typeMismatch".
Thus, this resolution algorithm can be leveraged for example
to show specific messages for binding errors like "required"
and "typeMismatch":
- at the object + field level ("age" field, but only on "user");
- field level (all "age" fields, no matter which object name);
- or general level (all fields, on any object).
- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
- Serialized Form
Constructor Summary |
protected |
FieldError(java.lang.String objectName,
java.lang.String field,
java.lang.Object rejectedValue,
boolean bindingFailure,
java.lang.String[] codes,
java.lang.Object[] args,
java.lang.String defaultMessage)
Create a new FieldError instance, using multiple codes. |
|
FieldError(java.lang.String objectName,
java.lang.String field,
java.lang.Object rejectedValue,
boolean bindingFailure,
java.lang.String code,
java.lang.Object[] args,
java.lang.String defaultMessage)
Create a new FieldError instance, using a default code. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
CODE_SEPARATOR
public static final java.lang.String CODE_SEPARATOR
- See Also:
- Constant Field Values
FieldError
public FieldError(java.lang.String objectName,
java.lang.String field,
java.lang.Object rejectedValue,
boolean bindingFailure,
java.lang.String code,
java.lang.Object[] args,
java.lang.String defaultMessage)
- Create a new FieldError instance, using a default code.
FieldError
protected FieldError(java.lang.String objectName,
java.lang.String field,
java.lang.Object rejectedValue,
boolean bindingFailure,
java.lang.String[] codes,
java.lang.Object[] args,
java.lang.String defaultMessage)
- Create a new FieldError instance, using multiple codes.
This is only meant to be used by subclasses.
- See Also:
MessageSourceResolvable.getCodes()
getField
public java.lang.String getField()
getRejectedValue
public java.lang.Object getRejectedValue()
isBindingFailure
public boolean isBindingFailure()
toString
public java.lang.String toString()
- Overrides:
toString
in class ObjectError
Copyright (C) 2003-2004 The Spring Framework Project.