Domanda

Di recente ho iniziato ad aggiornare alcune applicazioni per utilizzare Spring Webflow 2 e desidero utilizzare la nuova funzionalità Ajax fornita con Webflow 2. Qualcuno può indirizzarmi a un tutorial per l'integrazione di Tiles 2 con Spring Webflow ( dato che a quanto pare è quello che raccomandano). Ho trovato la documentazione fornita con Webflow 2 al riguardo assolutamente inutile.

È stato utile?

Soluzione

Questo è quello che ho fatto per farlo funzionare con webflow 2 e 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>

Altri suggerimenti

Questo non si riferisce esattamente alle funzioni di Ajax, ma mi ha aiutato a configurare le tessere apache 2 per flussi regolari:

http: / /jee-bpel-soa.blogspot.com/2008/12/spring-web-flows-2-and-tiles.html

Ci sono molti più dettagli al link, ma il bit di cui hai bisogno è un nuovo risolutore di viste:

<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>

È perfettamente spiegato nei documenti. Quindi, per favore, smetti di dirlo.

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

Come utilizzare le tessere in primavera: 10.5 Visualizza risoluzione (link + # spring-mvc-config-spring-view-risoluzione)

Come utilizzare Ajax con le tessere in primavera: 11.5: Gestire la richiesta Ajax (link + # spring-js-ajax)

Copia il codice da quei link e finirai con qualcosa del genere:

Configurazione per il flusso web per usare le tessere:

    <!-- 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>

Configurazione per piastrelle:

    <!-- 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>

Configurazione per piastrelle + 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>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top