我最近开始升级一些应用程序以使用Spring Webflow 2,我想利用Webflow 2附带的新Ajax功能。有人可以指导我将Tiles 2与Spring Webflow集成的教程(因为那显然是他们推荐的)。我发现Webflow 2附带的文档在这方面绝对没用。
答案 0 :(得分:3)
这并不完全是指ajax功能,但它帮助我为常规流程设置了apache tiles 2:
http://jee-bpel-soa.blogspot.com/2008/12/spring-web-flows-2-and-tiles.html
链接上有更多详细信息,但您需要的核心位是新的视图解析器:
<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" />
</bean>
<bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions" value="/WEB-INF/flows/main/main-tiles.xml" />
</bean>
答案 1 :(得分:2)
这是我使用webflow 2和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>
答案 2 :(得分:2)
在文档中完美地解释了这一点。所以,请停止说它不是。
如何在春天使用瓷砖:10.5查看分辨率(链接+#spring-mvc-config-spring-view-resolution)
如何在spring中使用带有tile的Ajax:11.5:处理Ajax请求(link +#spring-js-ajax)
从这些链接中复制代码,最终会得到如下内容:
配置webflow以使用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" />
</bean>
瓷砖配置:
<!-- Configures the Tiles layout system -->
<bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/views/layouts/page.xml</value>
<value>/WEB-INF/views/layouts/table.xml</value>
<value>/WEB-INF/views/globalViews.xml</value>
<value>/WEB-INF/views/userViews.xml</value>
</list>
</property>
</bean>
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" />
</bean>