2011-01-28 16 views
3

私は、Webflowを実現するためのビュー技術として、JSF2.0の統合に問題があります。 私はそれが "ほぼ"機能するように管理しましたが、残っているのはJSF2.0のためのajaxサポートを構成することだけです。jsf 2.0でspring webflowを設定するには?

Ajax要求が送信され、サーバーからの応答は受信されますが、応答はコンポーネントの再レンダリングをトリガーしません。問題を解決するために助けるために

少数の手がかり:

  • それはリソースへの.jsのリンクを生成することになると、JSFの行動が間違っています。これは、404背中を与える

    http://localhost:8080/$ {context_path}/$ {} flow_name /javax.faces.resource/ jsf.js LN = javax.faces :?JSFは、次のリンクにアクセスしようとします。 ?

    http://localhost:8080/$ {コンテキスト・パス} /javax.faces.resource/ jsf.js.faces LN =:私は、Ajaxサポートの一部を取得するためにハードコードにテンプレートで次のリンクを持っていましたjavax.faces(Web-Flowをオフに切り替えて、JSF処理済ページのソースコードを調べた後、このリンクを発見しました)

  • JSFの設定は正しいと仮定します。処理チェーンからWebflowをドロップすると、すべてが期待通りに機能します。リンクはOKですが、コンポーネントの再レンダリングはOKです

  • サービスを@ManagedBean(JSFネイティブアプローチ)として公開し、SpringバックBeanを使用しないと再レンダリングはうまく動作しますが、私はできません(web-flowにはネイティブの@ManagedBeansが表示されません)、ハードコードされたリンクを使用する必要があります。

  • 私はSpringリソースサーブレット/フィルタを持っていません。私は自分のフローに転送するためにurlRewriteルールを使用しません。

設定ファイルが必要な場合は、質問に投稿します。

何か助けていただければ幸いです。これはテクノロジースタック全体を使用することを阻む問題であると思われます。

答えて

1

手順:1つの web.xmlの

<?xml version="1.0" encoding="UTF-8"?> 
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
     id="WebApp_ID" version="2.5"> 
     <display-name>JSF2.0 with Spring webflow</display-name> 

    <context-param> 
      <param-name>contextConfigLocation</param-name> 
      <param-value> 
       /WEB-INF/config/web-application-config.xml 
      </param-value> 
     </context-param> 

     <context-param> 
      <param-name>javax.faces.PROJECT_STAGE</param-name> 
      <param-value>Production</param-value> 
     </context-param> 

     <context-param> 
      <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name> 
      <param-value>1</param-value> 
     </context-param> 

    <filter> 
      <filter-name>charEncodingFilter</filter-name> 
      <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> 
      <init-param> 
       <param-name>encoding</param-name> 
       <param-value>UTF-8</param-value> 
      </init-param> 
      <init-param> 
       <param-name>forceEncoding</param-name> 
       <param-value>true</param-value> 
      </init-param> 
     </filter> 

     <filter-mapping> 
      <filter-name>charEncodingFilter</filter-name> 
      <url-pattern>/*</url-pattern> 
     </filter-mapping> 

     <servlet> 
      <servlet-name>facesServlet</servlet-name> 
      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> 
      <load-on-startup>1</load-on-startup> 
     </servlet> 

     <servlet-mapping> 
      <servlet-name>facesServlet</servlet-name> 
      <url-pattern>/faces/*</url-pattern> 
     </servlet-mapping> 
     <servlet-mapping> 

      <servlet-name>facesServlet</servlet-name> 
      <url-pattern>*.jsf</url-pattern> 
     </servlet-mapping> 

     <servlet-mapping> 
      <servlet-name>facesServlet</servlet-name> 
      <url-pattern>*.faces</url-pattern> 
     </servlet-mapping> 

     <servlet-mapping> 
      <servlet-name>facesServlet</servlet-name> 
     <url-pattern>*.xhtml</url-pattern> 
     </servlet-mapping> 
<servlet> 
     <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> 
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     <init-param> 
      <param-name>contextConfigLocation</param-name> 
      <param-value></param-value> 
     </init-param> 
     <load-on-startup>2</load-on-startup> 
    </servlet> 

    <servlet-mapping> 
     <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> 
     <url-pattern>/spring/*</url-pattern> 
    </servlet-mapping> 


    <listener> 
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener> 

    <listener> 
     <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> 
    </listener> 

    <listener> 
     <listener-class>com.sun.faces.config.ConfigureListener</listener-class> 
    </listener> 
    <welcome-file-list> 
     <welcome-file>index.html</welcome-file> 
    </welcome-file-list> 
</web-app> 

ステップ:2つの 面-config.xmlの

 <?xml version='1.0' encoding='UTF-8'?> 
     <faces-config xmlns="http://java.sun.com/xml/ns/javaee" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" 
      version="2.0"> 
     </faces-config> 

ステップ:3 のWebflow-config.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-repository max-executions="1" /> 
     <webflow:flow-execution-attributes> 
      <webflow:always-redirect-on-pause value="true"/> 
     </webflow:flow-execution-attributes> 
     <webflow:flow-execution-listeners> 
      <webflow:listener ref="securityFlowExecutionListener"/> 
      <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="facesFlowBuilderServices" base-path="/WEB-INF/flows"> 
     <webflow:flow-location-pattern value="/**/*-flow.xml" /> 
    </webflow:flow-registry> 

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

    <!-- Installs a listener to apply Spring Security authorities --> 
    <bean id="securityFlowExecutionListener" class="org.springframework.webflow.security.SecurityFlowExecutionListener"/> 

     <!-- Installs a listener that creates and releases the FacesContext for each request. --> 
    <bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener"/> 


</beans> 

手順:4 webmvc-config.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: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/faces http://www.springframework.org/schema/faces/spring-faces-2.4.xsd 
     http://www.springframework.org/schema/mvc 
     http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> 

    <faces:resources /> 

    <!-- Maps request URIs to controllers. Here we have two kinds of flows one is login flow and another is main flow -->   
    <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> 
     <property name="mappings"> 
      <value> 
       /main=flowController 
       </value> 
     </property> 
     <property name="defaultHandler"> 
      <!-- Selects view names to render based on the request URI: e.g. /main selects "main" --> 
      <bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" /> 
     </property> 
    </bean> 

    <!-- it is used to handle the flow control Adaptor in 2.3.0. This will come from spring framework.web.servlet3.2.1 --> 
    <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" /> 

    <!-- Handles requests mapped to the Spring Web Flow system and ajaxHandler. 
    after security we need to enable the ajax for that we need to write one property i.e ajaxHandler --> 
    <bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController"> 
     <property name="flowExecutor" ref="flowExecutor" /> 
     <property name="ajaxHandler"> 
     <bean class="org.springframework.faces.webflow.JsfAjaxHandler"/> 
    </property> 
    </bean> 

    <!-- Maps logical view names to Facelet templates in /WEB-INF (e.g. 'search' to '/WEB-INF/search.xhtml' --> 
    <bean id="faceletsViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> 
     <property name="viewClass" value="org.springframework.faces.mvc.JsfView"/> 
     <property name="prefix" value="/WEB-INF/" /> 
     <property name="suffix" value=".xhtml" /> 
    </bean> 

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


</bean> 

</beans> 
0

最近、Spring WebflowプロジェクトでJSF 1からJSF 2への移行を行いました。後で、私はajaxが動作しないことを理解しました。私はwebmvc-configでこれら2つのbeanを設定しました。XML

最初のBeanはあなたがカント問題

<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter"> 
    <property name="flowExecutor" ref="flowExecutor"/> 
</bean> 

<bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter"> 
    <property name="flowExecutor" ref="flowExecutor" /> 
</bean> 

」はそれらの両方を持っていました。だから、ことを確認してください持っている。ここ

<bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter"> 
    <property name="flowExecutor" ref="flowExecutor" /> 
</bean> 

は、念のために私のプロジェクトではいくつかのフレームワークのバージョンのみJsfFlowHandlerAdapter

<spring.version>3.2.13.RELEASE</spring.version> 
    <jsf.version>2.2.8-02</jsf.version> 
    <org.springframework.webflow>2.4.0.RELEASE</org.springframework.webflow> 
    <org.springframework.security.version>3.2.4.RELEASE</org.springframework.security.version> 
関連する問題