Without spring:bind: If a validator fails and the controller executes showForm(...) to allow the user to correct the errors, the input controls will revert to their default values.
When the spring:bind tag is used to set the control value like this
Code:
<spring:bind path="command.property">
<input type="text" name="${status.expression}" value="${status.value}" />
</spring:bind>
the user will be presented with the erroneous value that caused validation to fail--which is more user-friendly than requiring the user to retyping the entire value.
Top Secret - Classified
I am almost finished with a set of JSP 2.0 tag files that will allow you to condense the above code down to something like this:
Code:
<html:input path="command.property"/>
By default the html:input tag uses type="text", but you can override the type by simply specifying a type attribute like this:
Code:
<html:input type="hidden" path="command.property"/>
You can also add any other random attribute like this (the resulting input tag will have them too):
Code:
<html:input path="command.property" class="myClass" size="50" foo="bar" />
And you can even override the value like this:
Code:
<html:input type="password" path="command.password" value="" />
They will soon be in the sandbox.