【问题标题】:Trying to get JSF(Faces) working within Spring WebFlow试图让 JSF(Faces) 在 Spring WebFlow 中工作
【发布时间】:2012-10-14 20:49:14
【问题描述】:

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

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

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

【问题讨论】:

    标签: jsf spring-mvc jsf-2 spring-webflow


    【解决方案1】:

    你需要像这样添加一个 Faces Context 监听器:

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

    【讨论】:

    • 它是否摆脱了异常,或者您是否再次遇到相同的异常。
    • 这里相同..不要用更新编辑问题。只需添加一个更新部分,保持之前的条目不变,然后根据我的回答添加您所做的更改。
    • 为我工作。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 2012-10-14
    • 2012-11-18
    • 2018-11-30
    • 2012-10-09
    • 2014-12-10
    • 1970-01-01
    • 2014-11-17
    • 1970-01-01
    相关资源
    最近更新 更多