Java Reference
In-Depth Information
Strategies with the Spring Framework
I have already introduced Spring page controllers in connection with the Front Controller
and Application Controller design patterns. I have also discussed the workflow involved
in identifying the appropriate page controller and also configuring them in the Spring
registry. However, I left the implementation details until now. In the next few sections, I
will explore the page controllers in greater detail.
Using Controller
Listing 3-16 shows the page controller implementation class that I have been referring to
and using in the previous examples.
Listing 3-16. CreatePolicyController.java
public class CreatePolicyController implements Controller {
private UnderwritingBusinessDelegate uwrBusinessDelegate;
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
//transform data from request to a form suitable for use in business layer
PolicyDetail policyDetail = new PolicyDetail();
policyDetail.setPolicyId(request.getParameter("policyId"));
//invoke business component
this.uwrBusinessDelegate.createPolicy(policyDetail);
Map model = new HashMap();
model.put("POLICY_DETAIL", policyDetail);
//return model and next view
return new ModelAndView("Success",model);
}
public void setUwrBusinessDelegate(
UnderwritingBusinessDelegate uwrBusinessDelegate) {
this.uwrBusinessDelegate = uwrBusinessDelegate;
}
}
 
Search WWH ::




Custom Search