org.springframework.validation
Class FieldError

java.lang.Object
  extended byorg.springframework.context.support.DefaultMessageSourceResolvable
      extended byorg.springframework.validation.ObjectError
          extended byorg.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:

E.g.: code "typeMismatch", field "age", object name "user":

Thus, this resolution algorithm can be leveraged for example to show specific messages for binding errors like "required" and "typeMismatch":

Author:
Rod Johnson, Juergen Hoeller
See Also:
Serialized Form

Field Summary
static java.lang.String CODE_SEPARATOR
           
 
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.
 
Method Summary
 java.lang.String getField()
           
 java.lang.Object getRejectedValue()
           
 boolean isBindingFailure()
           
 java.lang.String toString()
           
 
Methods inherited from class org.springframework.validation.ObjectError
getObjectName
 
Methods inherited from class org.springframework.context.support.DefaultMessageSourceResolvable
getArguments, getCode, getCodes, getDefaultMessage, resolvableToString, setArguments, setCodes, setDefaultMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CODE_SEPARATOR

public static final java.lang.String CODE_SEPARATOR
See Also:
Constant Field Values
Constructor Detail

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()
Method Detail

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.