Search code examples
springtilesspring-webflowtiles2

Integrating Spring Webflow 2 and Apache Tiles


I've recently started upgrading some applications to use Spring Webflow 2, and I want to make use of the new Ajax functionality that comes with Webflow 2. Can somebody please direct me to a tutorial for integrating Tiles 2 with Spring Webflow (since that's apparently what they recommend). I've found the documentation that comes with Webflow 2 in this regard to be absolutely useless.


Solution

  • This is what I did to get it working with webflow 2 and tiles 2.0

    <bean id="tilesConfigurer"
        class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
        <property name="definitions">
            <list>
                <value>/WEB-INF/tiles-defs/templates.xml</value>
            </list>
        </property>
    </bean>
    
    <bean id="urlMapping"
        class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="mappings">
            <props>
                <prop key="/flow/**/*.html">
                    flowController
                </prop>
                <prop key="/**/*.html">viewController</prop>
            </props>
        </property>
        <property name="order" value="1" />
    </bean>
    
    <bean id="tilesViewResolver"
        class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass"
            value="org.springframework.web.servlet.view.tiles2.TilesView" />
    </bean>
    
    <bean id="flowController"
        class="org.springframework.webflow.mvc.servlet.FlowController">
        <property name="flowExecutor" ref="flowExecutor" />
    </bean>
    
    <webflow:flow-executor id="flowExecutor"
        flow-registry="flowRegistry" />
    
    <webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices"
        base-path="/WEB-INF/flow/user">
        <webflow:flow-location path="/manage-users.xml" />
    </webflow:flow-registry>
    
    
    <webflow:flow-builder-services id="flowBuilderServices"
        view-factory-creator="viewFactoryCreator" />
    
    <bean id="viewFactoryCreator"
        class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
        <property name="viewResolvers" ref="tilesViewResolver" />
    </bean>