2012-10-24 25 views
1

我一直在試圖增加一些JSF(FACE)代碼到我的春節Webflow的項目,但我收到以下錯誤:試圖讓JSF(面)訪問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. 

這裏是我的流量。 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> 

回答

3

您需要添加Faces上下文監聽器是這樣的:

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

它沒有幫助! – techsjs2012

+0

它是否擺脫了異常,還是再次得到相同的異常。 – Ravi

+0

同樣在這裏..不要編輯與更新的問題。只需添加一個更新部分就可以不改變以前的條目,並根據我的anwser添加您已經更改的內容。 – Ravi