Expert Spring MVC and Web Flow

(Dana P.) #1
<table>

<spring:nestedPath path="account">

<tag:formField name="Username" path="username" />
<tag:formField name="Password" path="password" type="password"/>

</spring:nestedPath>

<tag:formField name="Confirm Password" path="confirmPassword" type="password"/>

<spring:nestedPath path="account">

<tag:formField name="Email" path="email" />

</spring:nestedPath>

<tr>
<td />
<td><input type="submit" value="Go to Step 2" /></td>
</tr>

</table>
</form>
</spring:nestedPath>

</body>
</html>

Notice that to the JSP file, the tag files are used just like any other tag element. The only
difference is found in the taglibdeclaration: when using tag files, you must specify a tagdir
attribute instead of a uriattribute. As with all JSP tags, the prefix is arbitrary, so feel free to use
whatever you like.
At least now the file has more XHTML elements than JSP elements, so I think we did a
good job. What should you take away from this? Creating user interface elements should fall
under the same scrutiny as your code. If you find yourself repeating yourself with similar snip-
pets in JSP files, take advantage of includes and tag files to minimize repetition and to create
more easily understood files.
With the new tag files complete, we are in a good position to create the second page of the
wizard, as shown in Listing 6-70.

Listing 6-70.Page 2: Enter Billing Address

<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="tag" %>

188 CHAPTER 6 ■THE CONTROLLER MENAGERIE

Free download pdf