试图让JSF(Faces)在Spring WebFlow中工作 [英] Trying to get JSF(Faces) working within Spring WebFlow

查看:95
本文介绍了试图让JSF(Faces)在Spring WebFlow中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的Spring Webflow项目中添加一些JSF(Face)代码,但出现以下错误:

I been trying to add some JSF(Face) code into my Spring Webflow project but I am getting the following error:

java.lang.IllegalStateException: FacesContext has not been initialized within the current Web Flow request. Check the configuration for your <webflow:flow-executor>. For JSF you will need FlowFacesContextLifecycleListener configured as one of its flow execution listeners.

这是我的flow.xml文件

Here is my flow.xml file

  <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:webflow="http://www.springframework.org/schema/webflow-config"
    xmlns:faces="http://www.springframework.org/schema/faces"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/webflow-config
        http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd
        http://www.springframework.org/schema/faces
        http://www.springframework.org/schema/faces/spring-faces-2.2.xsd">

    <!-- Executes flows: the central entry point into the Spring Web Flow system -->
    <webflow:flow-executor id="flowExecutor">
        <webflow:flow-execution-listeners>
            <webflow:listener ref="facesContextListener"/>
        </webflow:flow-execution-listeners>
    </webflow:flow-executor>

    <!-- The registry of executable flow definitions -->
    <webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF">
        <webflow:flow-location-pattern value="**/*-flow.xml" />
    </webflow:flow-registry>

    <!-- Configures the Spring Web Flow JSF integration -->
    <faces:flow-builder-services id="flowBuilderServices" />

    <!-- A listener maintain one FacesContext instance per Web Flow request. -->
    <bean id="facesContextListener" 
        class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" />  

</beans>

这是我的流程:

<flow xmlns="http://www.springframework.org/schema/webflow"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/webflow
                          http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">

    <var name="customer" class="org.smith.webflowtemplate.domain.Customer"/>


    <view-state id="checkbox-input" model="customer" >
            <transition on="submit" to="preview" validate="false"/>
            <transition on="cancel" to="thanks" validate="false"/>
    </view-state>

    <view-state id="preview"  model="customer">
                <transition on="accept" to="endState"/>
     </view-state>

    <end-state id="endState" view="/index.jsp"  />

</flow>

推荐答案

您需要添加Faces Context侦听器,如下所示:

You need to add a Faces Context listener like this:

<flow-executor id="flowExecutor">
        <flow-execution-listeners>
            <listener ref="facesContextListener" />
        </flow-execution-listeners>
</flow-executor>

<beans:bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" />

这篇关于试图让JSF(Faces)在Spring WebFlow中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆