Ich bin noch relativ neu in der Materie. Ich habe mir eine kleine CRUD-Anwendung mit Spring 5 und JSP geschrieben. Diese funktioniert soweit auch super.
Ich möchte diese jetzt auf JSF für die Components umstellen. Wohl gemerkt JSF Components und nicht JSF MVC. Das Spring MVC soll weiter verwendet werden.
Hierzu habe ich mir die Spring Dokumentation bzgl. JSF integration durchgelesen.
https://docs.spring.io/autorepo/docs/webflow/2.4.2.RELEASE/reference/html/spring-faces.html
Aber irgendwie fehlt mir immer noch das Verständnis wie es sauber implementiert wird.
Bis jetzt habe ich die javax-faces-2.2.8.jar eingebunden.
Meine spring context xml datei sieht wie folgt aus
jap-spring-servlet.xml
faces-config.xml
web.xml
Der URL-Pattern wurde so denke ich korrekt eingestellt. So denke ich.
Die Spring MVC soll auf alle urls ausgehend von meiner Domain "localhost:8080"
entsprechend aufgerufen werden ("<url-pattern>/*</url-pattern>")
Ab 13.5. Configuring WebFlow for use with JSF
wirds für mich leicht unverständlich.
Wo muss sich diese Datei befinden? Wie muss ich die Datei benennen für das obige Zitat?
Soweit ich es bis jetzt Verstanden habe würde dieses ausreichen um einfache JSF Components mit Spring MVC zu verwenden?
Danke für eure Hilfe
Ich möchte diese jetzt auf JSF für die Components umstellen. Wohl gemerkt JSF Components und nicht JSF MVC. Das Spring MVC soll weiter verwendet werden.
Hierzu habe ich mir die Spring Dokumentation bzgl. JSF integration durchgelesen.
https://docs.spring.io/autorepo/docs/webflow/2.4.2.RELEASE/reference/html/spring-faces.html
Aber irgendwie fehlt mir immer noch das Verständnis wie es sauber implementiert wird.
Bis jetzt habe ich die javax-faces-2.2.8.jar eingebunden.
Meine spring context xml datei sieht wie folgt aus
jap-spring-servlet.xml
Code:
<?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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- Add support for component scanning -->
<context:component-scan base-package="com.abado.jap" />
<!-- Add support for conversion, formatting and validation support -->
<mvc:annotation-driven/>
<!-- Define Spring MVC view resolver -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- Step 1: Define Database DataSource / connection pool -->
<bean id="japDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/jap?useSSL=false" />
<property name="user" value="root" />
<property name="password" value="" />
<!-- these are connection pool properties for C3P0 -->
<property name="initialPoolSize" value="5"/>
<property name="minPoolSize" value="5" />
<property name="maxPoolSize" value="20" />
<property name="maxIdleTime" value="30000" />
</bean>
<!-- Step 2: Setup Hibernate session factory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="japDataSource" />
<property name="packagesToScan" value="com.abado.jap.entities" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<!-- Step 3: Setup Hibernate transaction manager -->
<bean id="myTransactionManager"
class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- Step 4: Enable configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="myTransactionManager" />
<!-- Add support for reading web resources: css, images, js, etc ... -->
<mvc:resources location="/resources/" mapping="/resources/**"></mvc:resources>
<mvc:resources location="/css/" mapping="/css/**"></mvc:resources>
<mvc:resources location="/images/" mapping="/images/**"></mvc:resources>
<mvc:resources location="/js/" mapping="/js/**"></mvc:resources>
</beans>
faces-config.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
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"
version="2.2">
</faces-config>
web.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>JSFExample</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
Der URL-Pattern wurde so denke ich korrekt eingestellt. So denke ich.
Die Spring MVC soll auf alle urls ausgehend von meiner Domain "localhost:8080"
entsprechend aufgerufen werden ("<url-pattern>/*</url-pattern>")
Ab 13.5. Configuring WebFlow for use with JSF
wirds für mich leicht unverständlich.
Code:<?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" si:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.4.xsd http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces-2.4.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>
Wo muss sich diese Datei befinden? Wie muss ich die Datei benennen für das obige Zitat?
Soweit ich es bis jetzt Verstanden habe würde dieses ausreichen um einfache JSF Components mit Spring MVC zu verwenden?
Danke für eure Hilfe