spring-framework / org.springframework.web.reactive.result.view / BindStatus

BindStatus

open class BindStatus

Simple adapter to expose the bind status of a field or object. Set as a variable by FreeMarker macros and other tag libraries.

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
Rossen Stoyanchev

Since
5.0

See Also
RequestContext#getBindStatus

Constructors

<init>

BindStatus(requestContext: RequestContext, path: String, htmlEscape: Boolean)

Create a new BindStatus instance, representing a field or object status.

Functions

findEditor

open fun findEditor(valueClass: Class<*>): PropertyEditor

Find a PropertyEditor for the given value class, associated with the property that this bound status is currently bound to.

getActualValue

open fun getActualValue(): Any

Return the actual value of the field, i.e. the raw property value, or null if not available.

getDisplayValue

open fun getDisplayValue(): String

Return 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 toString result of the original value will get HTML-escaped.

getEditor

open fun getEditor(): PropertyEditor

Return the PropertyEditor for the property that this bind status is currently bound to.

getErrorCode

open fun getErrorCode(): String

Return the first error codes for the field or object, if any.

getErrorCodes

open fun getErrorCodes(): Array<String>

Return the error codes for the field or object, if any. Returns an empty array instead of null if none.

getErrorMessage

open fun getErrorMessage(): String

Return the first error message for the field or object, if any.

getErrorMessages

open fun getErrorMessages(): Array<String>

Return the resolved error messages for the field or object, if any. Returns an empty array instead of null if none.

getErrorMessagesAsString

open fun getErrorMessagesAsString(delimiter: String): String

Return an error message string, concatenating all messages separated by the given delimiter.

getErrors

open fun getErrors(): Errors

Return the Errors instance (typically a BindingResult) that this bind status is currently associated with.

getExpression

open fun getExpression(): String

Return a bind expression that can be used in HTML forms as input name for the respective field, or 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.

getPath

open fun getPath(): String

Return the bean and property path for which values and errors will be resolved (e.g. "customer.address.street").

getValue

open fun getValue(): Any

Return the current value of the field, i.e. either the property value or a rejected update, or null if not field-specific.

This value will be an HTML-escaped String if the original value already was a String.

getValueType

open fun getValueType(): Class<*>

Get the 'Class' type of the field. Favor this instead of 'getValue().getClass()' since 'getValue()' may return 'null'.

isError

open fun isError(): Boolean

Return if this status represents a field or object error.

toString

open fun toString(): String