Hello,
I want to use Java Server Faces with Spring Webflow (2.0.6) but it does not work correctly ...
The webpage itself looks very nice but the problem is that the action event (of my commandButton) is not recognized by the flow. So the state does not change to the next view-state "step2".
Does anybody know what's going wrong?
I'am really new at spring and webapplications. So it would be nice if you could give me some more detaild information.
Thank you very much!
best regards
web.xml:
faces-config.xml:Code:<?xml version="1.0" encoding="ISO-8859-1"?> <web-app 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" version="2.4"> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/services-config.xml </param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class> org.springframework.web.context.request.RequestContextListener</listener-class> </listener> <servlet> <servlet-name>phonebook</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/phonebook-webflow-config.xml /WEB-INF/phonebook-servlet-config.xml </param-value> </init-param> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>phonebook</servlet-name> <url-pattern>*.htm</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.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> <!-- 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> <servlet-mapping> <servlet-name>faces Servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> <listener> <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class> </listener> </web-app>
phonebook-flow.xml:Code:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN" "http://java.sun.com/dtd/web-facesconfig_1_0.dtd"> <faces-config> <application> <variable-resolver> org.springframework.web.jsf.DelegatingVariableResolver </variable-resolver> <!-- Enables Facelets --> <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> </application> </faces-config>
step1.xhtml:Code:<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" start-state="step1"> <on-start> <set name="flowScope.person" value="personFactory.getNewPerson()"></set> </on-start> <view-state id="step1" view="step1"> <transition on="next" to="step2" /> </view-state> <view-state id="step2" view="step2"> <transition on="previous" to="step1" /> </view-state> </flow>
step2.xhtml:Code:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jstl/core"> <body> <h1>Testfrom (Schritt 1)</h1> <h:form> <p>Vorname: <h:inputText id="firstname" value="#{flowScope.person.firstname}" /></p> <p>Nachname: <h:inputText id="surname" value="#{flowScope.person.surname}" /></p> <p>Telefon: <h:inputText id="phonenumber" value="#{flowScope.person.phonenumber}" /></p> <h:commandButton value="next" action="next" /> </h:form> </body> </html>
phonebook-servlet-config.xml:Code:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jstl/core"> <body> <h1>Testfrom (Schritt 2)</h1> <h:form> <p>Vorname: #{flowScope.person.firstname}</p> <p>Nachname: #{flowScope.person.surname}</p> <p>Telefon: #{flowScope.person.phonenumber}</p> <h:commandButton value="previous" action="previous"></h:commandButton> </h:form> </body> </html>
Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:flow="http://www.springframework.org/schema/webflow-config" 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-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd 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/faces http://www.springframework.org/schema/faces/spring-faces-2.0.xsd"> <!-- ================================================================== Spring MVC stuff ================================================================== --> <!-- This activates post-processors for annotation-based config --> <!-- http://www.infoq.com/articles/spring-2.5-part-1 --> <context:annotation-config /> <context:component-scan base-package="phonebook" /> <!-- Enables POJO @Controllers (like CartController) --> <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" /> <!-- Maps flow requests from DispatcherServlet to flowController --> <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <value> /*.htm=flowController </value> </property> <property name="alwaysUseFullPath" value="true" /> </bean> <!-- Enables annotated methods on POJO @Controllers (like CartController) --> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /> <!-- Enables plain Controllers (e.g. FlowController) --> <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" /> <!-- Maps a logical view name to a physical resource --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/pages/" /> <property name="suffix" value=".xhtml" /> </bean> <!-- ================================================================== Spring Web Flow stuff ================================================================== --> <!-- Using FlowController instead of FlowHandlers; see SWF Reference Guide, section 9.5. --> <bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController"> <property name="flowExecutor" ref="flowExecutor" /> </bean> <flow:flow-executor id="flowExecutor" flow-registry="flowRegistry" /> <!-- This creates an XmlFlowRegistryFactory bean --> <flow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices"> <flow:flow-location-pattern value="/WEB-INF/flows/*-flow.xml" /> </flow:flow-registry> <flow:flow-builder-services id="flowBuilderServices" view-factory-creator="viewFactoryCreator" /> <bean id="viewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator"> <property name="viewResolvers"> <list> <ref bean="viewResolver" /> </list> </property> </bean> <!-- ================================================================== Spring Faces stuff ================================================================== --> <!-- <flow:flow-registry id="flowRegistry" flow-builder-services="facesFlowBuilderServices"> <flow:flow-location-pattern value="/WEB-INF/flows/*-flow.xml" /> </flow:flow-registry> <faces:flow-builder-services id="facesFlowBuilderServices" /> --> </beans>


Reply With Quote
