Wednesday, October 19, 2011

Spring Webflow MVC JSF (Richfaces 4) Servlet

This allows the seperation of servlet config to the servlet decleration:

<servlet>
<servlet-name>Spring MVC Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

Configuration:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<!-- DispatcherServlet Context: defines this servlet's request-processing
infrastructure -->

<!-- Enables the Spring MVC @Controller programming model -->
<mvc:annotation-driven />

<!-- Maps request paths to flows in the flowRegistry -->
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
<property name="order" value="-2" />
<property name="flowRegistry" ref="flowRegistry" />
</bean>

<!-- Resolves views selected for rendering by @Controllers to .xhtml resources
in the /WEB-INF/views directory -->
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.faces.mvc.JsfView" />
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".xhtml" />
</bean>

<!-- Dispatches requests mapped to flows to FlowHandler implementations -->
<bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
<property name="flowExecutor" ref="flowExecutor" />
</bean>

<bean name="jsfResourceHandler"
class="org.springframework.faces.webflow.JsfResourceRequestHandler" />

<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="order" value="0" />
<property name="mappings">
<value>/javax.faces.resource/**=jsfResourceHandler
/rfRes/**=jsfResourceHandler
</value>
</property>
</bean>

<bean class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter" />

<bean
class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />

<flow-executor id="flowExecutor">
<flow-execution-listeners>
<listener ref="facesContextListener" />
</flow-execution-listeners>
</flow-executor>

<!-- The registry of executable flow definitions -->
<flow-registry id="flowRegistry" flow-builder-services="facesFlowBuilderServices"
base-path="/WEB-INF/flows">
<flow-location-pattern value="/**/flow.xml" />
</flow-registry>

<faces:flow-builder-services id="facesFlowBuilderServices" development="true" />

<bean id="facesContextListener"
class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" />

</beans>

No comments:

Post a Comment