<context:component-scan base-package="com.apress.prospring3.ch18.web" />
<beans:bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
<beans:property name="flowRegistry" ref="flowRegistry" />
</beans:bean>
<beans:bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<beans:property name="viewClass"
value="org.springframework.faces.mvc.JsfView" />
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".xhtml" />
</beans:bean>
<beans:bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
<beans:property name="flowExecutor" ref="flowExecutor" />
</beans:bean>
<beans:bean
class="org.springframework.context.support.ReloadableResourceBundleMessageSource"
id="messageSource"
p:basenames="WEB-INF/i18n/messages,WEB-INF/i18n/application"
p:fallbackToSystemLocale="false"/>
</beans:beans>
In Listing 18-4, most of the beans should be familiar to you. First, the configuration in webflow.xml is
imported. The <faces:resources/> tag is to enable the support of JSF 2 resource requests. The
anonymous bean with class FlowHandlerMapping implements Spring MVC's HandlerMapping interface for
integration with Spring MVC in the Spring Web Flow environment. It maps the URL path to the id of the
registered flow definitions.
For the view resolver, we use the same UrlBasedViewResolver in Spring MVC, with the suffix
changed to xhtml. The anonymous bean with the implementation class JsfFlowHandlerAdapter replaces
the instance of the default AjaxHandler interface (under the package org.springframework.js.ajax of
the spring-js module) with a JsfAjaxHandler class (under the package
org.springframework.faces.webflow in the spring-faces module) when JSF 2 is the runtime
environment.
Finally, the bean with ID messageSource is the same as the one for Spring MVC.
Implementing the Sample Flow
Now the infrastructure and configurations are complete, and we can start to implement the add contact
flow. In the following sections, we will go through the steps to implement the flow. Various steps,
including the flow definition, template view, various contact views, controller class, backing bean
classes, and so on, will be discussed.
Define the Flow Definition
Let's begin with defining the contact application flow, which was illustrated in Figure 18-7. As discussed
in the configuration section, the flow definition file is /WEB-INF/flows/contacts/flow.xml. There is a
convenient way to create a web flow definition file in STS. Just right-click the contacts folder, choose
New, and then choose Spring Web Flow Definition File. Listing 18-5 shows the flow definition.
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home