org.springframework.validation
Class BindException

java.lang.Object
  |
  +--java.lang.Throwable
        |
        +--java.lang.Exception
              |
              +--org.springframework.validation.BindException

public class BindException
extends Exception
implements Errors

Default implementation of the Errors interface, supporting registration and evaluation of binding errors. Slightly unusual, as it is an exception.

This is mainly a framework-internal class. Normally, application code will work with the Errors interface, or a DataBinder that in turn exposes a BindException via getErrors().

Supports exporting a model, suitable for example for web MVC. Thus, it is sometimes used as parameter type instead of the Errors interface itself - if extracting the model makes sense in the respective context.

Author:
Rod Johnson, Juergen Hoeller
See Also: getModel(), DataBinder.getErrors()

Field Summary
 final static StringERROR_KEY_PREFIX
          Prefix for the name of the Errors instance in a model, followed by the object name.

Constructor Summary
BindException(Object target, String name)
          Create a new BindException instance.

Method Summary
 ListgetAllErrors()
           
 PropertyEditorgetCustomEditor(String field)
           
 intgetErrorCount()
           
 FieldErrorgetFieldError(String field)
           
 intgetFieldErrorCount(String field)
           
 ListgetFieldErrors(String field)
           
 ObjectgetFieldValue(String field)
           
 ObjectErrorgetGlobalError()
           
 intgetGlobalErrorCount()
           
 ListgetGlobalErrors()
           
 StringgetMessage()
          Returns diagnostic information about the errors held in this object.
 final MapgetModel()
          Return a model Map for the obtained state, exposing an Errors instance as 'ERROR_KEY_PREFIX + objectName' and the object itself.
 StringgetObjectName()
           
 ObjectgetTarget()
          Return the wrapped target object.
 booleanhasErrors()
           
 booleanhasFieldErrors(String field)
           
 booleanhasGlobalErrors()
           
 voidreject(String errorCode, String defaultMessage)
           
 voidreject(String errorCode, Object[] errorArgs, String defaultMessage)
           
 voidrejectValue(String field, String errorCode, String defaultMessage)
           
 voidrejectValue(String field, String errorCode, Object[] errorArgs, String defaultMessage)
           
 voidsetNestedPath(String nestedPath)
           

Methods inherited from class java.lang.Throwable
printStackTrace, printStackTrace, printStackTrace, getStackTrace, setStackTrace, getLocalizedMessage, toString, fillInStackTrace, getCause, initCause

Methods inherited from class java.lang.Object
hashCode, notify, notifyAll, wait, wait, wait, getClass, equals

Field Detail

ERROR_KEY_PREFIX

public final static String ERROR_KEY_PREFIX
Prefix for the name of the Errors instance in a model, followed by the object name.
Constructor Detail

BindException

public BindException(Object target, String name)
Create a new BindException instance.
Parameters:
target - target object to bind onto
name - name of the target object
Method Detail

getAllErrors

public List getAllErrors()

getCustomEditor

public PropertyEditor getCustomEditor(String field)

getErrorCount

public int getErrorCount()

getFieldError

public FieldError getFieldError(String field)

getFieldErrorCount

public int getFieldErrorCount(String field)

getFieldErrors

public List getFieldErrors(String field)

getFieldValue

public Object getFieldValue(String field)

getGlobalError

public ObjectError getGlobalError()

getGlobalErrorCount

public int getGlobalErrorCount()

getGlobalErrors

public List getGlobalErrors()

getMessage

public String getMessage()
Returns diagnostic information about the errors held in this object.

getModel

public final Map getModel()
Return a model Map for the obtained state, exposing an Errors instance as 'ERROR_KEY_PREFIX + objectName' and the object itself.

Note that the Map is constructed each time you're calling this method, adding things to the map and then re-calling it will not do...

See Also:
getObjectName(), ERROR_KEY_PREFIX

getObjectName

public String getObjectName()

getTarget

public Object getTarget()
Return the wrapped target object.

hasErrors

public boolean hasErrors()

hasFieldErrors

public boolean hasFieldErrors(String field)

hasGlobalErrors

public boolean hasGlobalErrors()

reject

public void reject(String errorCode, String defaultMessage)

reject

public void reject(String errorCode, Object[] errorArgs, String defaultMessage)

rejectValue

public void rejectValue(String field, String errorCode, String defaultMessage)

rejectValue

public void rejectValue(String field, String errorCode, Object[] errorArgs, String defaultMessage)

setNestedPath

public void setNestedPath(String nestedPath)

Association Links

to Class java.lang.String

Prefix for the name of the Errors instance in a model, followed by the object name.

to Class java.util.List

to Class org.springframework.beans.BeanWrapper

to Class java.lang.String

to Class java.lang.String