30

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?

Ogo Pogo
  • 303
  • 1
  • 3
  • 5

2 Answers2

24

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
  • 103,016
  • 27
  • 158
  • 194
  • 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 Feb 03 '10 at 14:15
6

The bind tag documentation of Spring 3.0

See Also: BindStatus

C. Ross
  • 31,137
  • 42
  • 147
  • 238
Stefan Birkner
  • 24,059
  • 12
  • 57
  • 72
  • Thanks for linking that, but it's awful weak. It would be nice if they linked to [BindStatus](http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/web/servlet/support/BindStatus.html) at least. – C. Ross Mar 04 '13 at 13:30