Java Reference
In-Depth Information
<bean name="/saveNewPolicy.do"
class="com.apress.insurance.web.controller.SaveNewPolicyController" >
<property name="uwrBusinessDelegate"
ref="underwritingBusinessDelegate" />
</bean>
<bean name="underwritingBusinessDelegate"
class="com.apress.insurance.view.delegate.UnderWritingBusinessDelegate" />
</beans>
The web page that is presented to the end user's browser to create a policy does not
require any dynamic data. Hence, I have configured a UrlFilenameViewController object
to handle this request. It converts a resource name in the URL into a logical view name.
So, the request for createPolicy.do will result in a symbolic view name: createPolicy . The
SimpleUrlHandlerMapping with wildcard mapping resolves any request starting with create ,
such as createPolicy.do , and invokes the UrlFilenameViewController , which returns the
logical view name. Finally, the view resolver is invoked by the front controller to resolve
the logical view name to a physical resource, /WEB-INF/jsp/createPolicy.jsp .
In createPolicy.jsp (Listing 3-20), whenever the user clicks the Save button, a
request is sent to the server for the resource saveNewPolicy.do . Now a handler mapping
chain has been configured in Listing 3-23. The BeanNameUrlHandlerMapping with higher
precedence is able to resolve this URL and invokes the SaveNewPolicyController . The
logical view name returned by this controller is finally resolved to the resource
showPolicydetails.jsp .
Using SimpleFormController
A typical web application involves displaying a form to collect user input. The users
fill in this form and submit the data to the web server for further processing.
SimpleFormController is widely used to provide page controller implementations because
it coordinates and manages the two most important aspects of a form's life cycle—view
and submission. As with many other Spring MVC classes, this one also implements the
template design pattern and is closed for modification but open for extension at suitable
points of the workflow. The workflow can also be altered by setting various configurable
properties.
Form Display
I will first look at the form display feature provided by the SimpleFormController class.
Figure 3-10 shows the workflow of this function.
 
Search WWH ::




Custom Search