tags:

views:

5711

answers:

1

Let's discuss on the following example:

<spring:bind path="user.userName">
    <input type="text" name="${status.expression}" value="${status.value}"/>
    <span class="fieldError">${status.errorMessage}</span>
</spring:bind>

When this view snippet gets rendered, what do ${status.expression} and ${status.value} get evaluated to? Where do these values come from?

+2  A: 

See this link for an explanation of what the status variables mean.

  • status.expression: the expression that was used to retrieve the bean or property
  • status.value: the actual value of the bean or property (transformed using registered PropertyEditors)
  • status.errorMessages: an array of error messages, resulting from validation

The status object is evaluated when the binding is done.

Also have in mind that Spring 2.0 introduced new form tags, which are probable better suited for your needs.

kgiannakakis
Thanks for the reminder that the value of `status.value` is generated by the registered PropertyEditor. I implemented a custom editor for setting a property and omitted the `getAsText()` method. This will result in `"null"` strings!
Koraktor