public class BindStatus
extends java.lang.Object
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.
RequestContext.getBindStatus(java.lang.String)
,
BindTag
,
AbstractTemplateView.setExposeSpringMacroHelpers(boolean)
Modifier and Type | Field and Description |
---|---|
private java.lang.Object |
actualValue |
private BindingResult |
bindingResult |
private java.beans.PropertyEditor |
editor |
private java.lang.String[] |
errorCodes |
private java.lang.String[] |
errorMessages |
private Errors |
errors |
private java.lang.String |
expression |
private boolean |
htmlEscape |
private java.util.List<? extends ObjectError> |
objectErrors |
private java.lang.String |
path |
private RequestContext |
requestContext |
private java.lang.Object |
value |
private java.lang.Class<?> |
valueType |
Constructor and Description |
---|
BindStatus(RequestContext requestContext,
java.lang.String path,
boolean htmlEscape)
Create a new BindStatus instance, representing a field or object status.
|
Modifier and Type | Method and Description |
---|---|
java.beans.PropertyEditor |
findEditor(java.lang.Class<?> valueClass)
Find a PropertyEditor for the given value class, associated with
the property that this bound status is currently bound to.
|
java.lang.Object |
getActualValue()
Return the actual value of the field, i.e.
|
java.lang.String |
getDisplayValue()
Return a suitable display value for the field, i.e.
|
java.beans.PropertyEditor |
getEditor()
Return the PropertyEditor for the property that this bind status
is currently bound to.
|
java.lang.String |
getErrorCode()
Return the first error codes for the field or object, if any.
|
java.lang.String[] |
getErrorCodes()
Return the error codes for the field or object, if any.
|
java.lang.String |
getErrorMessage()
Return the first error message for the field or object, if any.
|
java.lang.String[] |
getErrorMessages()
Return the resolved error messages for the field or object,
if any.
|
java.lang.String |
getErrorMessagesAsString(java.lang.String delimiter)
Return an error message string, concatenating all messages
separated by the given delimiter.
|
Errors |
getErrors()
Return the Errors instance (typically a BindingResult) that this
bind status is currently associated with.
|
java.lang.String |
getExpression()
Return a bind expression that can be used in HTML forms as input name
for the respective field, or
null if not field-specific. |
java.lang.String |
getPath()
Return the bean and property path for which values and errors
will be resolved (e.g.
|
java.lang.Object |
getValue()
Return the current value of the field, i.e.
|
java.lang.Class<?> |
getValueType()
Get the '
Class ' type of the field. |
private void |
initErrorCodes()
Extract the error codes from the ObjectError list.
|
private void |
initErrorMessages()
Extract the error messages from the ObjectError list.
|
boolean |
isError()
Return if this status represents a field or object error.
|
java.lang.String |
toString() |
private final RequestContext requestContext
private final java.lang.String path
private final boolean htmlEscape
private final java.lang.String expression
private final Errors errors
private BindingResult bindingResult
private java.lang.Object value
private java.lang.Class<?> valueType
private java.lang.Object actualValue
private java.beans.PropertyEditor editor
private java.util.List<? extends ObjectError> objectErrors
private java.lang.String[] errorCodes
private java.lang.String[] errorMessages
public BindStatus(RequestContext requestContext, java.lang.String path, boolean htmlEscape) throws java.lang.IllegalStateException
requestContext
- the current RequestContextpath
- the bean and property path for which values and errors
will be resolved (e.g. "customer.address.street")htmlEscape
- whether to HTML-escape error messages and string valuesjava.lang.IllegalStateException
- if no corresponding Errors object foundprivate void initErrorCodes()
private void initErrorMessages() throws NoSuchMessageException
NoSuchMessageException
public java.lang.String getPath()
public java.lang.String getExpression()
null
if not field-specific.
Returns a bind path appropriate for resubmission, e.g. "address.street". Note that the complete bind path as required by the bind tag is "customer.address.street", if bound to a "customer" bean.
public java.lang.Object getValue()
null
if not field-specific.
This value will be an HTML-escaped String if the original value already was a String.
public java.lang.Class<?> getValueType()
Class
' type of the field. Favor this instead of
'getValue().getClass()
' since 'getValue()
' may
return 'null
'.public java.lang.Object getActualValue()
null
if not available.public java.lang.String getDisplayValue()
This value will be an HTML-escaped String if the original value
was non-null: the toString
result of the original value
will get HTML-escaped.
public boolean isError()
public java.lang.String[] getErrorCodes()
public java.lang.String getErrorCode()
public java.lang.String[] getErrorMessages()
public java.lang.String getErrorMessage()
public java.lang.String getErrorMessagesAsString(java.lang.String delimiter)
delimiter
- separator string, e.g. ", " or "public Errors getErrors()
null
if noneBindingResult
public java.beans.PropertyEditor getEditor()
null
if nonepublic java.beans.PropertyEditor findEditor(java.lang.Class<?> valueClass)
valueClass
- the value class that an editor is needed fornull
if nonepublic java.lang.String toString()
toString
in class java.lang.Object