<p/>
<form:label path="birthDate">
${labelContactBirthDate}
</form:label>
<form:input path="birthDate" id="birthDate"/>
<div>
<form:errors path="birthDate" cssClass="error" />
</div>
<p/>
<form:label path="description">
${labelContactDescription}
</form:label>
<form:textarea cols="60" rows="8" path="description" id="contactDescription"/>
<div>
<form:errors path="description" cssClass="error" />
</div>
<p/>
<form:hidden path="version" />
<button type="submit">Save</button>
<button type="reset">Reset</button>
</form:form>
</div>
</div>
The highlights for Listing 17-34 are as follows:
The <spring:eval> tag is used, which uses the Spring Expression Language to test
·
whether the contact id is null. If yes, then it's a new contact; otherwise, it's an
update. The corresponding form title will be displayed.
Various Spring MVC <form> tags are used within the form for displaying the label,
·
the input field, and errors in case binding was not successful on form submission.
Next, add the view mapping to the view definition file (/views/contacts/views.xml). Listing 17-35
shows the code snippet.
Listing 17-35. The Edit Contact View Mapping
<definition extends="default" name="contacts/update">
<put-attribute name="body"
value="/WEB-INF/views/contacts/edit.jspx" />
</definition>
The edit view is completed. Then rebuild and deploy the project. Click the edit link in Figure 17-12.
The edit view will be displayed, as shown in Figure 17-13.
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home