Merging of SWF-367 back into trunk. This has all of the SWF 2.0 goodies.
This commit is contained in:
@@ -2,10 +2,10 @@ package org.springframework.webflow.samples.booking.flow.booking;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.springframework.binding.message.Messages;
|
||||
import org.springframework.binding.message.Severity;
|
||||
import org.springframework.webflow.action.MultiAction;
|
||||
import org.springframework.webflow.execution.Event;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
@@ -54,15 +54,12 @@ public class BookingActions extends MultiAction {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
if (booking.getCheckinDate().before(calendar.getTime())) {
|
||||
FacesContext.getCurrentInstance().addMessage("checkinDate",
|
||||
new FacesMessage(FacesMessage.SEVERITY_ERROR, "Check in date must be a future date", ""));
|
||||
context.getMessageContext().addMessage(
|
||||
Messages.text("checkinDate", "Check in date must be a future date", Severity.ERROR));
|
||||
return error();
|
||||
} else if (!booking.getCheckinDate().before(booking.getCheckoutDate())) {
|
||||
FacesContext.getCurrentInstance()
|
||||
.addMessage(
|
||||
"checkoutDate",
|
||||
new FacesMessage(FacesMessage.SEVERITY_ERROR,
|
||||
"Check out date must be later than check in date", ""));
|
||||
context.getMessageContext().addMessage(
|
||||
Messages.text("checkoutDate", "Check out date must be later than check in date", Severity.ERROR));
|
||||
return error();
|
||||
}
|
||||
return success();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?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:flow="http://www.springframework.org/schema/webflow-config"
|
||||
xmlns:web="http://www.springframework.org/schema/webflow-config"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
@@ -11,36 +11,33 @@
|
||||
<!-- Imports the "application-layer" definining business logic and data access services -->
|
||||
<import resource="application-layer-config.xml"/>
|
||||
|
||||
<!-- Launches new flow executions and resumes existing executions -->
|
||||
<flow:executor id="flowExecutor" registry-ref="flowRegistry">
|
||||
<flow:execution-attributes>
|
||||
<flow:alwaysRedirectOnPause value="false"/>
|
||||
</flow:execution-attributes>
|
||||
<flow:execution-listeners>
|
||||
<flow:listener ref="jpaConversationListener"/>
|
||||
</flow:execution-listeners>
|
||||
</flow:executor>
|
||||
|
||||
<!-- Creates the registry of flow definitions for this application -->
|
||||
<bean id="flowRegistry" class="org.springframework.webflow.engine.builder.xml.XmlFlowRegistryFactoryBean">
|
||||
<property name="expressionParser" ref="jsfExpressionParser"/>
|
||||
<property name="flowLocations">
|
||||
<list>
|
||||
<value>/flow/main/main.xml</value>
|
||||
<value>/flow/booking/booking.xml</value>
|
||||
</list>
|
||||
<web:flow-executor id="flowExecutor" flow-registry="flowRegistry">
|
||||
<web:flow-execution-listeners>
|
||||
<web:listener ref="jpaFlowExecutionListener" criteria="*"/>
|
||||
</web:flow-execution-listeners>
|
||||
</web:flow-executor>
|
||||
|
||||
<web:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
|
||||
<web:flow-location path="flow/main/main.xml" />
|
||||
<web:flow-location path="flow/booking/booking.xml" />
|
||||
<web:flow-builder class="org.springframework.faces.ui.resource.ResourcesFlowBuilder" />
|
||||
</web:flow-registry>
|
||||
|
||||
<bean id="flowBuilderServices" class="org.springframework.webflow.engine.builder.support.FlowBuilderServices">
|
||||
<property name="expressionParser">
|
||||
<bean class="org.springframework.webflow.core.expression.el.WebFlowELExpressionParser">
|
||||
<constructor-arg >
|
||||
<bean class="org.jboss.el.ExpressionFactoryImpl"/>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="viewFactoryCreator">
|
||||
<bean class="org.springframework.webflow.engine.builder.xml.JsfViewFactoryCreator"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Enables use of the unified expression language (EL) from flow definitions -->
|
||||
<bean id="jsfExpressionParser" class="org.springframework.faces.el.Jsf12ELExpressionParser">
|
||||
<constructor-arg >
|
||||
<bean class="org.jboss.el.ExpressionFactoryImpl"/>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<!-- Installs a listener that manages JPA persistence contexts for flows that require them -->
|
||||
<bean id="jpaConversationListener" class="org.springframework.webflow.persistence.JpaFlowExecutionListener">
|
||||
<bean id="jpaFlowExecutionListener" class="org.springframework.webflow.persistence.JpaFlowExecutionListener">
|
||||
<constructor-arg>
|
||||
<ref bean="entityManagerFactory"/>
|
||||
</constructor-arg>
|
||||
|
||||
@@ -4,53 +4,40 @@
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
|
||||
version="2.4">
|
||||
|
||||
<!-- The location of the configuration of this Spring Faces application; a path to a Spring configuration file -->
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>
|
||||
/WEB-INF/config/web-application-config.xml
|
||||
</param-value>
|
||||
</context-param>
|
||||
|
||||
<!-- 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>
|
||||
|
||||
<!-- Bootstraps the "root" Spring WebApplicationContext, responsible for deploying the managed beans
|
||||
defined in the web-application-config.xml file above. These beans define the back-end services of the JSF application. -->
|
||||
<listener>
|
||||
<listener-class>
|
||||
org.springframework.web.context.ContextLoaderListener
|
||||
</listener-class>
|
||||
</listener>
|
||||
|
||||
<!-- Guarantees that under all JSF exit conditions, the flow context will be cleaned up -->
|
||||
<filter>
|
||||
<filter-name>Flow System Cleanup Filter</filter-name>
|
||||
<filter-class>
|
||||
org.springframework.faces.webflow.FlowSystemCleanupFilter
|
||||
</filter-class>
|
||||
</filter>
|
||||
|
||||
<!-- Runs all requests to *.spring through the FlowSystemCleanupFilter for guarenteed cleanup -->
|
||||
<filter-mapping>
|
||||
<filter-name>Flow System Cleanup Filter</filter-name>
|
||||
<url-pattern>*.spring</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
<!-- The front controller of the JSF application, responsible for handling all application requests -->
|
||||
<!-- 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>
|
||||
|
||||
<!-- Map all *.spring requests to the Faces Servlet for handling -->
|
||||
<!-- Dummy mapping for faces initialization -->
|
||||
<servlet-mapping>
|
||||
<servlet-name>Faces Servlet</servlet-name>
|
||||
<url-pattern>*.spring</url-pattern>
|
||||
<url-pattern>*.faces</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- The front controller of the Spring Web application, responsible for handling all application requests -->
|
||||
<servlet>
|
||||
<servlet-name>Spring Web Servlet</servlet-name>
|
||||
<servlet-class>org.springframework.webflow.servlet.SpringWebServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>configLocations</param-name>
|
||||
<param-value>/WEB-INF/config/web-application-config.xml</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<!-- Map all *.spring requests to the Web Servlet for handling -->
|
||||
<servlet-mapping>
|
||||
<servlet-name>Spring Web Servlet</servlet-name>
|
||||
<url-pattern>/spring/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<welcome-file-list>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
<start-state idref="displayHotel"/>
|
||||
|
||||
<view-state id="displayHotel" view="/flow/booking/hotelDetails.xhtml">
|
||||
<view-state id="displayHotel" view="hotelDetails.xhtml">
|
||||
<render-actions>
|
||||
<bean-action method="findHotelById" bean="bookingService">
|
||||
<method-arguments>
|
||||
@@ -36,14 +36,14 @@
|
||||
<transition on="success" to="enterBookingDetails" />
|
||||
</action-state>
|
||||
|
||||
<view-state id="enterBookingDetails" view="/flow/booking/bookingForm.xhtml">
|
||||
<view-state id="enterBookingDetails" view="bookingForm.xhtml">
|
||||
<transition on="proceed" to="confirmBooking">
|
||||
<action method="validateBooking" bean="bookingActions" />
|
||||
</transition>
|
||||
<transition on="cancel" to="cancel" />
|
||||
</view-state>
|
||||
|
||||
<view-state id="confirmBooking" view="/flow/booking/confirmBooking.xhtml">
|
||||
<view-state id="confirmBooking" view="confirmBooking.xhtml">
|
||||
<transition on="confirm" to="bookingAuthorized" />
|
||||
<transition on="revise" to="enterBookingDetails" />
|
||||
<transition on="cancel" to="cancel" />
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
<start-state idref="displayMain"/>
|
||||
|
||||
<view-state id="displayMain" view="/flow/main/main.xhtml">
|
||||
<view-state id="displayMain" view="main.xhtml">
|
||||
<transition on="findHotels" to="findHotels" />
|
||||
<transition on="selectHotel" to="bookHotel" />
|
||||
<transition on="cancelBooking" to="cancelBooking" />
|
||||
@@ -29,7 +29,7 @@
|
||||
<subflow-state id="bookHotel" flow="booking">
|
||||
<attribute-mapper>
|
||||
<input-mapper>
|
||||
<mapping source="param.hotelId" target="id" from="string" to="long" />
|
||||
<mapping source="requestParameters.hotelId" target="id" from="string" to="long" />
|
||||
</input-mapper>
|
||||
</attribute-mapper>
|
||||
<transition on="bookingAuthorized" to="reloadCurrentUserBookings" />
|
||||
@@ -39,7 +39,7 @@
|
||||
<action-state id="cancelBooking">
|
||||
<bean-action method="cancelBooking" bean="bookingService">
|
||||
<method-arguments>
|
||||
<argument expression="param.bookingId" parameter-type="long"/>
|
||||
<argument expression="#{requestParameters.bookingId}" parameter-type="long"/>
|
||||
</method-arguments>
|
||||
</bean-action>
|
||||
<transition on="success" to="reloadCurrentUserBookings" />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Refresh" content="0; URL=intro.spring">
|
||||
<meta http-equiv="Refresh" content="0; URL=spring/main">
|
||||
</head>
|
||||
</html>
|
||||
Reference in New Issue
Block a user