Integracja JSF oraz Spring WebFlow

0

Macie może przykład konfiguracji JSF ze Spring WebFlow? Ewentualnie czy ktoś mógłby spojrzeć na kod poniżej? Jak uruchomić stronę index?

jsf-webflow-integration\src\main\resources\spring\webflow-context.xml

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

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

    <flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF/flows">
        <flow-location-pattern value="/**/*-flow.xml"/>
    </flow-registry>

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

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

    <beans:bean id="faceletsViewResolver"  class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <beans:property name="viewClass" value="org.springframework.faces.mvc.JsfView"/>
        <beans:property name="prefix" value="/WEB-INF/pages/" />
        <beans:property name="suffix" value=".xhtml" />
    </beans:bean>

</beans:beans>

jsf-webflow-integration\src\main\webapp\WEB-INF\flows\parent-flow.xml

<?xml version="1.0" encoding="UTF-8"?>
<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">

    <view-state id="index"/>

</flow>

jsf-webflow-integration\src\main\webapp\WEB-INF\pages\index.xhtml

<html>
<body>
	<h1>It works</h1>
</body>
</html>

jsf-webflow-integration\src\main\webapp\WEB-INF\faces-config.xml

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

    <application>
        <!-- Enables Facelets -->
        <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
    </application>

</faces-config>

jsf-webflow-integration\src\main\webapp\WEB-INF\web.xml

<web-app version="2.4"
	xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
	http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

	<display-name>Spring MVC Application</display-name>

    <!-- Spring Context Locations -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:/spring/*-context.xml</param-value>
    </context-param>

    <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>/WEB-INF/spring/web-mvc.xml</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>

    <!-- Just here so the JSF implementation can initialize, *not* used at runtime -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- Just here so the JSF implementation can initialize -->
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.faces</url-pattern>
    </servlet-mapping>

    <!-- Obsługa niezmiennych zasobów z plików jar.  -->
    <servlet>
        <servlet-name>Resource Servlet</servlet-name>
        <servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
        <load-on-startup>0</load-on-startup>
    </servlet>

    <!-- Mapowanie wszystkich żądań /resources do servletu ResourceServlet do obsługi -->
    <servlet-mapping>
        <servlet-name>Resource Servlet</servlet-name>
        <url-pattern>/resources/*</url-pattern>
    </servlet-mapping>

    <!-- Use JSF view templates saved as *.xhtml, for use with Facelets -->
    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>

</web-app>
0

A czy stosuje się w praktyce połączenie: Spring MVC + JSF + Spring WebFlow?
Jakie połączenia z JSF oraz WebFlow są najczęsciej wykorzystywane?

0

czekaj, JSF nie jest widokiem - to jest już MVC, po co Ci Spring MVC + JSF(też MVC) ? Możesz bez większego problemu do aplikacji JSF dodać Springa i jego DI (czyli jakby @ManagedBean zamieniasz na @Component ).

0

A połączenie JSF + Spring WebFlow?

0

Mam prawie gotowe połączenie Spring WebFlow + JSF, ale nie działa to jeszcze tak jakbym chciał.
Gdy kliknę w link na stronie start.xhtml dostaję błąd 404 zamiast strony test.xhtml, która powinna sie otworzyć za pomocą webflow.
Jakby komuś chciało się do tego zajrzeć i mi pomóc to podsyłam link na githuba:

https://github.com/bakeraw2/spring-webflow-jsf-integration

1 użytkowników online, w tym zalogowanych: 0, gości: 1