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.


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

<bean id="tilesConfigurer"
	<property name="definitions">

<bean id="urlMapping"
	<property name="mappings">
			<prop key="/flow/**/*.html">
			<prop key="/**/*.html">viewController</prop>
	<property name="order" value="1" />

<bean id="tilesViewResolver"
	<property name="viewClass"
		value="org.springframework.web.servlet.view.tiles2.TilesView" />

<bean id="flowController"
	<property name="flowExecutor" ref="flowExecutor" />

<webflow:flow-executor id="flowExecutor"
	flow-registry="flowRegistry" />

<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices"
	<webflow:flow-location path="/manage-users.xml" />

<webflow:flow-builder-services id="flowBuilderServices"
	view-factory-creator="viewFactoryCreator" />

<bean id="viewFactoryCreator"
	<property name="viewResolvers" ref="tilesViewResolver" />

This isn't exactly referring to the ajax features, but it helped me get apache tiles 2 set up for regular flows:

A lot more details are at the link, but the core bit you need is a new view resolver:

<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" />
<bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    <property name="definitions" value="/WEB-INF/flows/main/main-tiles.xml" />

It's perfectly explained in the docs. So, please, stop saying it isn't.

How to use tiles in spring: 10.5 View resolution (link + #spring-mvc-config-spring-view-resolution)

How to use Ajax with tiles in spring: 11.5: Handling Ajax request (link + #spring-js-ajax)

Copy the code from those links and you will end up with something like this:

Configuration for webflow to use Tiles:

    <!-- Plugs in a custom creator for Web Flow views -->
<webflow:flow-builder-services id="flowBuilderServices" view-factory-creator="mvcViewFactoryCreator" />

<!-- Configures Web Flow to use Tiles to create views for rendering; Tiles allows for applying consistent layouts to your views -->
<bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
	<property name="viewResolvers" ref="tilesViewResolver" />

Configuration for Tiles:

    <!-- Configures the Tiles layout system -->
<bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
	<property name="definitions">

Configuration for Tiles + Ajax:

  - This bean configures the UrlBasedViewResolver, which resolves logical view names 
  - by delegating to the Tiles layout system. A view name to resolve is treated as
  - the name of a tiles definition.
<bean id="tilesViewResolver" class="org.springframework.js.ajax.AjaxUrlBasedViewResolver">
	<property name="viewClass" value="org.springframework.webflow.mvc.view.FlowAjaxTilesView" />

Need Your Help

Different “request” implicit objects in Liferay

java servlets attributes request liferay

What is the difference between fetching attributes from these implicit objects:

Can I null-check in-line?

java null nullpointerexception

I have a Java command that looks something like below:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.