Class BindStatus
java.lang.Object
org.springframework.web.servlet.support.BindStatus
Simple adapter to expose the bind status of a field or object.
 Set as a variable both by the JSP bind tag and FreeMarker macros.
 
Obviously, object status representations (i.e. errors at the object level rather than the field level) do not have an expression and a value but only error codes and messages. For simplicity's sake and to be able to use the same tags and macros, the same status class is used for both scenarios.
- Author:
- Rod Johnson, Juergen Hoeller, Darren Davison
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionBindStatus(RequestContext requestContext, String path, boolean htmlEscape) Create a new BindStatus instance, representing a field or object status.
- 
Method SummaryModifier and TypeMethodDescriptionfindEditor(Class<?> valueClass) Find a PropertyEditor for the given value class, associated with the property that this bound status is currently bound to.Return the actual value of the field, i.e.Return a suitable display value for the field, i.e.Return the PropertyEditor for the property that this bind status is currently bound to.Return the first error codes for the field or object, if any.String[]Return the error codes for the field or object, if any.Return the first error message for the field or object, if any.String[]Return the resolved error messages for the field or object, if any.getErrorMessagesAsString(String delimiter) Return an error message string, concatenating all messages separated by the given delimiter.Return the Errors instance (typically a BindingResult) that this bind status is currently associated with.Return a bind expression that can be used in HTML forms as input name for the respective field, ornullif not field-specific.getPath()Return the bean and property path for which values and errors will be resolved (for example, "customer.address.street").getValue()Return the current value of the field, i.e.Class<?>Get the 'Class' type of the field.booleanisError()Return if this status represents a field or object error.toString()
- 
Constructor Details- 
BindStatuspublic BindStatus(RequestContext requestContext, String path, boolean htmlEscape) throws IllegalStateException Create a new BindStatus instance, representing a field or object status.- Parameters:
- requestContext- the current RequestContext
- path- the bean and property path for which values and errors will be resolved (for example, "customer.address.street")
- htmlEscape- whether to HTML-escape error messages and string values
- Throws:
- IllegalStateException- if no corresponding Errors object found
 
 
- 
- 
Method Details- 
getPathReturn the bean and property path for which values and errors will be resolved (for example, "customer.address.street").
- 
getExpressionReturn a bind expression that can be used in HTML forms as input name for the respective field, ornullif not field-specific.Returns a bind path appropriate for resubmission, for example, "address.street". Note that the complete bind path as required by the bind tag is "customer.address.street", if bound to a "customer" bean. 
- 
getValueReturn the current value of the field, i.e. either the property value or a rejected update, ornullif not field-specific.This value will be an HTML-escaped String if the original value already was a String. 
- 
getValueTypeGet the 'Class' type of the field. Favor this instead of 'getValue().getClass()' since 'getValue()' may return 'null'.
- 
getActualValueReturn the actual value of the field, i.e. the raw property value, ornullif not available.
- 
getDisplayValueReturn a suitable display value for the field, i.e. the stringified value if not null, and an empty string in case of a null value.This value will be an HTML-escaped String if the original value was non-null: the toStringresult of the original value will get HTML-escaped.
- 
isErrorpublic boolean isError()Return if this status represents a field or object error.
- 
getErrorCodesReturn the error codes for the field or object, if any. Returns an empty array instead of null if none.
- 
getErrorCodeReturn the first error codes for the field or object, if any.
- 
getErrorMessagesReturn the resolved error messages for the field or object, if any. Returns an empty array instead of null if none.
- 
getErrorMessageReturn the first error message for the field or object, if any.
- 
getErrorMessagesAsStringReturn an error message string, concatenating all messages separated by the given delimiter.- Parameters:
- delimiter- separator string, for example, ", " or "
 "
- Returns:
- the error message string
 
- 
getErrorsReturn the Errors instance (typically a BindingResult) that this bind status is currently associated with.- Returns:
- the current Errors instance, or nullif none
- See Also:
 
- 
getEditorReturn the PropertyEditor for the property that this bind status is currently bound to.- Returns:
- the current PropertyEditor, or nullif none
 
- 
findEditorFind a PropertyEditor for the given value class, associated with the property that this bound status is currently bound to.- Parameters:
- valueClass- the value class that an editor is needed for
- Returns:
- the associated PropertyEditor, or nullif none
 
- 
toString
 
-