6

我最近开始升级一些应用程序以使用 Spring Webflow 2,并且我想利用 Webflow 2 附带的新 Ajax 功能。有人可以指导我学习将 Tiles 2 与 Spring Webflow 集成的教程(因为这显然是他们推荐什么)。我发现 Webflow 2 附带的文档在这方面完全没用。

4

3 回答 3

3

这并不完全是指 ajax 功能,但它帮助我为常规流程设置了 apache tile 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>
于 2009-05-08T04:28:58.190 回答
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>
于 2009-07-09T01:02:31.760 回答
2

它在文档中得到了完美的解释。所以,请不要再说它不是。

http://static.springsource.org/spring-webflow/docs/2.0.x/reference/htmlsingle/spring-webflow-reference.html

如何在春季使用瓷砖:10.5 查看分辨率(链接 + #spring-mvc-config-spring-view-resolution)

如何在春季使用 Ajax 与瓷砖:11.5:处理 Ajax 请求(链接 + #spring-js-ajax)

从这些链接中复制代码,您最终会得到如下内容:

使用 Tiles 的 webflow 配置:

    <!-- 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>
于 2009-07-23T15:45:21.400 回答