Java Reference
In-Depth Information
Listing 3-51. WEB-INF/jsp/createPolicy.jsp
<%@ taglib prefix="form" uri=" http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri=" http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri=" http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
<title>Underwriting</title>
<style>
.error { color: red; }
</style>
</head>
<form:form action="" method="POST" commandName="policydetails">
First Name <form:input path="firstName"/> <form:errors path="firstName"
cssClass="error"/><br/>
Last Name <form:input path="lastName"/> <form:errors path="lastName"
cssClass="error"/><br/>
Age <form:input path="age"/> <form:errors path="age" cssClass="error"/><br/>
Product Code <form:select path="productCodeList" items="${productCodeList}"/>
<form:errors path="productCodeList" cssClass="error"/><br/>
<input type="submit" value="Save" />
</form:form>
</body>
</html>
A list of product code is prepopulated and cached at application startup. It is
retrieved and supplied in the form bean by the controller (see in Listing 3-52) by
overriding the formBackingObject method.
Listing 3-52. SaveNewPolicyController.java
public class SaveNewPolicyController extends SimpleFormController {
private UnderWritingBusinessDelegate uwrBusinessDelegate;
protected void doSubmitAction(Object formbean) throws Exception {
PolicyFormBean policyBean = (PolicyFormBean)formbean;
uwrBusinessDelegate.createPolicy(policyBean);
}
Search WWH ::




Custom Search