Java Reference
In-Depth Information
First Name <input type="text" name="firstName" value="" /><br/>
Last Name <input type="text" name="lastName" value="" /><br/>
Age <input type="text" name="age" value="" /><br/>
<input type="submit" value="Save" />
</form>
</body>
</html>
SaveNewPolicyController now extends the SimpleFormController as shown in
Listing 3-25. Note that this version is suitable only for form display.
Listing 3-25. SaveNewPolicyController.java
public class SaveNewPolicyController extends SimpleFormController {
private UnderWritingBusinessDelegate uwrBusinessDelegate;
public SaveNewPolicyController() {
setCommandClass(PolicyFormBean.class);
}
public void setUwrBusinessDelegate(
UnderWritingBusinessDelegate uwrBusinessDelegate) {
this.uwrBusinessDelegate = uwrBusinessDelegate;
}
}
Finally, I will wire up the beans in the Spring configuration file as shown in
Listing 3-26. This is a very clean configuration. A GET request for /createPolicy.do is inter-
cepted by the SaveNewPolicyController , which considers this as a form display request.
The property formView serves as a logical view name, which is resolved to the physical
view /WEB-INF/jsp/createPolicy.jsp to present the form to the end user.
Listing 3-26. insurance-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=" http://www.springframework.org/schema/beans"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
 
Search WWH ::




Custom Search