Listing 8-7.Binding Without Nesting Paths
<spring:bind path="complexCommand.collection.item">
<input type="text" name="<c:out value="${status.expression}"/>"
value="<c:out value="${status.value}"/>"/>
</spring:bind>
<br>
<spring:bind path="complexCommand.collection.item2">
<input type="text" name="<c:out value="${status.expression}"/>"
value="<c:out value="${status.value}"/>"/>
</spring:bind>
As you can see, we’re showing binding to two imaginary items in a collection field of a
command object. It’s a bit verbose and a maintenance headache if you have a lot of these
items to bind fields to. Listing 8-8 has the same form, this time using a nested path.
Listing 8-8.Binding with Nested Paths
<spring:nestedPath path="complexCommand.collection">
<spring:bind path="item">
<input type="text" name="<c:out value="${status.expression}"/>"
value="<c:out value="${status.value}"/>"/>
</spring:bind>
<br>
<spring:bind path="item2">
<input type="text" name="<c:out value="${status.expression}"/>"
value="<c:out value="${status.value}"/>"/>
</spring:bind>
</spring:nestedPath>
Notice now, that when executing inside a nested path, the bind path is significantly
shorter, taking its prefix from the path exported by the <spring:nestedPath>tag instead.
A Note on Check Box Submissions
Check boxes are handy for displaying Boolean-type data in your forms, but they can be a nui-
sance too. A deficiency in the way HTML form POSTs work means that if a check box appears
on a form but it is not actually checked, then the field will not be submitted by the browser at
all in the list of POST parameters.
This can be a problem for your applications. Consider the following scenario:
•A user selects a check box on a form and submits it.
•Other validation errors cause the form to be shown again to the user; the check box is
correctly checked as per her original choice.
•She corrects the errors, but also changes her mind about the check box selection and
unchecks it.
230 CHAPTER 8 ■SUPPORTED VIEW TYPES