SWF-1234 Integration with Spring 3 type conversion

This commit is contained in:
Rossen Stoyanchev
2010-05-04 11:12:32 +00:00
parent 7372b31184
commit de75aefc63
51 changed files with 630 additions and 743 deletions

View File

@@ -32,11 +32,12 @@
<dependency org="org.hibernate" name="com.springsource.org.hibernate.annotations" rev="3.3.0.ga" conf="compile->runtime"/>
<dependency org="org.hibernate" name="com.springsource.org.hibernate.ejb" rev="3.3.1.ga" conf="compile->runtime"/>
<dependency org="org.hsqldb" name="com.springsource.org.hsqldb" rev="1.8.0.9" conf="compile->runtime"/>
<dependency org="org.jboss.el" name="com.springsource.org.jboss.el" rev="2.0.0.GA" conf="compile->runtime"/>
<dependency org="org.joda" name="com.springsource.org.joda.time" rev="1.6.0" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.aop" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.beans" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.context" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.core" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.expression" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.jdbc" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.orm" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.transaction" rev="3.0.2.RELEASE" conf="compile->runtime"/>

View File

@@ -53,9 +53,9 @@
<version>1.8.0.9</version>
</dependency>
<dependency>
<groupId>org.jboss.el</groupId>
<artifactId>com.springsource.org.jboss.el</artifactId>
<version>2.0.0.GA</version>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
@@ -77,6 +77,11 @@
<artifactId>org.springframework.core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.jdbc</artifactId>

View File

@@ -36,12 +36,13 @@
<dependency org="org.hibernate" name="com.springsource.org.hibernate.annotations" rev="3.3.0.ga" conf="compile->runtime"/>
<dependency org="org.hibernate" name="com.springsource.org.hibernate.ejb" rev="3.3.1.ga" conf="compile->runtime"/>
<dependency org="org.hsqldb" name="com.springsource.org.hsqldb" rev="1.8.0.9" conf="compile->runtime"/>
<dependency org="org.ognl" name="com.springsource.org.ognl" rev="2.6.9" conf="compile->runtime"/>
<dependency org="org.joda" name="com.springsource.org.joda.time" rev="1.6.0" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.aop" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.beans" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.context" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.context.support" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.core" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.expression" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.jdbc" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.orm" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.transaction" rev="3.0.2.RELEASE" conf="compile->runtime"/>

View File

@@ -73,9 +73,9 @@
<version>1.8.0.9</version>
</dependency>
<dependency>
<groupId>org.ognl</groupId>
<artifactId>com.springsource.org.ognl</artifactId>
<version>2.6.9</version>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
@@ -102,6 +102,11 @@
<artifactId>org.springframework.core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.jdbc</artifactId>

View File

@@ -1,18 +0,0 @@
package org.springframework.webflow.samples.booking;
import org.springframework.binding.convert.converters.StringToDate;
import org.springframework.binding.convert.service.DefaultConversionService;
import org.springframework.stereotype.Component;
@Component("conversionService")
public class ApplicationConversionService extends DefaultConversionService {
@Override
protected void addDefaultConverters() {
super.addDefaultConverters();
StringToDate dateConverter = new StringToDate();
dateConverter.setPattern("MM-dd-yyyy");
addConverter("shortDate", dateConverter);
}
}

View File

@@ -20,6 +20,7 @@ import javax.persistence.Transient;
import org.springframework.binding.message.MessageBuilder;
import org.springframework.binding.message.MessageContext;
import org.springframework.binding.validation.ValidationContext;
import org.springframework.format.annotation.DateTimeFormat;
/**
* A Hotel Booking made by a User.
@@ -32,8 +33,10 @@ public class Booking implements Serializable {
private Hotel hotel;
@DateTimeFormat(pattern = "MM-dd-yyyy")
private Date checkinDate;
@DateTimeFormat(pattern = "MM-dd-yyyy")
private Date checkoutDate;
private String creditCard;
@@ -73,7 +76,7 @@ public class Booking implements Serializable {
if (checkinDate == null || checkoutDate == null) {
return 0;
} else {
return (int) (checkoutDate.getTime() - checkinDate.getTime()) / 1000 / 60 / 60 / 24;
return (int) ((checkoutDate.getTime() - checkinDate.getTime()) / 1000 / 60 / 60 / 24);
}
}

View File

@@ -22,8 +22,8 @@
</webflow:flow-registry>
<!-- Plugs in a custom creator for Web Flow views -->
<webflow:flow-builder-services id="flowBuilderServices" view-factory-creator="mvcViewFactoryCreator" conversion-service="conversionService" development="true" />
<webflow:flow-builder-services id="flowBuilderServices" view-factory-creator="mvcViewFactoryCreator" development="true" />
<!-- Configures Web Flow to use Tiles to create views for rendering; Tiles allows for applying consistent layouts to your views -->
<bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
<property name="viewResolvers" ref="tilesViewResolver"/>

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!-- Maps request paths to flows in the flowRegistry; e.g. a path of /hotels/booking looks for a flow with id "hotels/booking" -->
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">

View File

@@ -10,13 +10,13 @@
<input name="hotelId" required="true" />
<on-start>
<evaluate expression="bookingService.createBooking(hotelId, currentUser.name)" result="flowScope.booking" />
<evaluate expression="bookingService.createBooking(hotelId, currentUser.name)" result="flowScope.booking" />
</on-start>
<view-state id="enterBookingDetails" model="booking">
<binder>
<binding property="checkinDate" converter="shortDate" required="true" />
<binding property="checkoutDate" converter="shortDate" required="true" />
<binding property="checkinDate" required="true" />
<binding property="checkoutDate" required="true" />
<binding property="beds" required="true" />
<binding property="smoking" required="true" />
<binding property="creditCard" required="true" />

View File

@@ -34,11 +34,12 @@
<dependency org="org.hibernate" name="com.springsource.org.hibernate.annotations" rev="3.3.0.ga" conf="compile->compile"/>
<dependency org="org.hibernate" name="com.springsource.org.hibernate.ejb" rev="3.3.1.ga" conf="compile->compile"/>
<dependency org="org.hsqldb" name="com.springsource.org.hsqldb" rev="1.8.0.9" conf="compile->compile"/>
<dependency org="org.jboss.el" name="com.springsource.org.jboss.el" rev="2.0.0.GA" conf="compile->compile"/>
<dependency org="org.joda" name="com.springsource.org.joda.time" rev="1.6.0" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.aop" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.beans" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.context" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.core" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.expression" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.jdbc" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.orm" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.transaction" rev="3.0.2.RELEASE" conf="compile->compile"/>

View File

@@ -58,9 +58,9 @@
<version>1.8.0.9</version>
</dependency>
<dependency>
<groupId>org.jboss.el</groupId>
<artifactId>com.springsource.org.jboss.el</artifactId>
<version>2.0.0.GA</version>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
@@ -82,6 +82,11 @@
<artifactId>org.springframework.core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.jdbc</artifactId>

View File

@@ -21,7 +21,6 @@
<dependencies>
<!-- core dependencies -->
<dependency org="javax.el" name="com.springsource.javax.el" rev="1.0.0" conf="provided->compile"/>
<dependency org="javax.persistence" name="com.springsource.javax.persistence" rev="1.0.0" conf="compile->compile"/>
<dependency org="javax.portlet" name="com.springsource.javax.portlet" rev="2.0.0" conf="provided->compile"/>
<dependency org="javax.servlet" name="com.springsource.javax.servlet" rev="2.4.0" conf="provided->compile"/>
@@ -34,11 +33,12 @@
<dependency org="org.hibernate" name="com.springsource.org.hibernate.annotations" rev="3.3.0.ga" conf="compile->compile"/>
<dependency org="org.hibernate" name="com.springsource.org.hibernate.ejb" rev="3.3.1.ga" conf="compile->compile"/>
<dependency org="org.hsqldb" name="com.springsource.org.hsqldb" rev="1.8.0.9" conf="compile->compile"/>
<dependency org="org.jboss.el" name="com.springsource.org.jboss.el" rev="2.0.0.GA" conf="compile->compile"/>
<dependency org="org.joda" name="com.springsource.org.joda.time" rev="1.6.0" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.aop" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.beans" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.context" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.core" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.expression" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.jdbc" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.orm" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.transaction" rev="3.0.2.RELEASE" conf="compile->compile"/>

View File

@@ -48,9 +48,9 @@
<version>1.8.0.9</version>
</dependency>
<dependency>
<groupId>org.jboss.el</groupId>
<artifactId>com.springsource.org.jboss.el</artifactId>
<version>2.0.0.GA</version>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
@@ -72,6 +72,11 @@
<artifactId>org.springframework.core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.jdbc</artifactId>
@@ -119,12 +124,6 @@
<version>2.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>com.springsource.javax.el</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>com.springsource.javax.servlet</artifactId>

View File

@@ -16,6 +16,8 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import org.springframework.format.annotation.DateTimeFormat;
/**
* A Hotel Booking made by a User.
*/
@@ -27,8 +29,10 @@ public class Booking implements Serializable {
private Hotel hotel;
@DateTimeFormat(pattern = "MM-dd-yyyy")
private Date checkinDate;
@DateTimeFormat(pattern = "MM-dd-yyyy")
private Date checkoutDate;
private String creditCard;

View File

@@ -21,32 +21,33 @@
<dependencies>
<!-- core dependencies -->
<dependency org="com.sun.facelets" name="com.springsource.com.sun.facelets" rev="1.1.14" conf="compile->compile"/>
<dependency org="com.sun.faces" name="com.springsource.com.sun.faces" rev="1.2.0.09" conf="compile->compile" />
<dependency org="javax.el" name="com.springsource.javax.el" rev="1.0.0" conf="provided->compile"/>
<dependency org="javax.faces" name="com.springsource.javax.faces" rev="1.2.0.09" conf="compile->compile" />
<dependency org="javax.persistence" name="com.springsource.javax.persistence" rev="1.0.0" conf="compile->compile"/>
<dependency org="javax.servlet" name="com.springsource.javax.servlet" rev="2.4.0" conf="provided->compile"/>
<dependency org="javax.servlet" name="com.springsource.javax.servlet.jsp.jstl" rev="1.1.2" conf="compile->compile"/>
<dependency org="javax.transaction" name="com.springsource.javax.transaction" rev="1.1.0" conf="compile->compile"/>
<dependency org="org.apache.log4j" name="com.springsource.org.apache.log4j" rev="1.2.15" conf="compile->compile"/>
<dependency org="org.hibernate" name="com.springsource.org.hibernate" rev="3.2.6.ga" conf="compile->compile"/>
<dependency org="org.hibernate" name="com.springsource.org.hibernate.annotations" rev="3.3.0.ga" conf="compile->compile"/>
<dependency org="org.hibernate" name="com.springsource.org.hibernate.ejb" rev="3.3.1.ga" conf="compile->compile"/>
<dependency org="org.hsqldb" name="com.springsource.org.hsqldb" rev="1.8.0.9" conf="compile->compile"/>
<dependency org="org.jboss.el" name="com.springsource.org.jboss.el" rev="2.0.0.GA" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.aop" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.beans" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.context" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.core" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.jdbc" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.orm" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.transaction" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="org.springframework" name="org.springframework.web" rev="3.0.2.RELEASE" conf="compile->compile"/>
<dependency org="com.sun.facelets" name="com.springsource.com.sun.facelets" rev="1.1.14" conf="compile->runtime"/>
<dependency org="javax.el" name="com.springsource.javax.el" rev="1.0.0" conf="provided->runtime"/>
<dependency org="com.sun.faces" name="com.springsource.com.sun.faces" rev="1.2.0.09" conf="compile->runtime" />
<dependency org="javax.faces" name="com.springsource.javax.faces" rev="1.2.0.09" conf="compile->runtime" />
<dependency org="javax.persistence" name="com.springsource.javax.persistence" rev="1.0.0" conf="compile->runtime"/>
<dependency org="javax.servlet" name="com.springsource.javax.servlet" rev="2.4.0" conf="provided->runtime"/>
<dependency org="javax.servlet" name="com.springsource.javax.servlet.jsp.jstl" rev="1.1.2" conf="compile->runtime"/>
<dependency org="javax.transaction" name="com.springsource.javax.transaction" rev="1.1.0" conf="compile->runtime"/>
<dependency org="org.apache.log4j" name="com.springsource.org.apache.log4j" rev="1.2.15" conf="compile->runtime"/>
<dependency org="org.hibernate" name="com.springsource.org.hibernate" rev="3.2.6.ga" conf="compile->runtime"/>
<dependency org="org.hibernate" name="com.springsource.org.hibernate.annotations" rev="3.3.0.ga" conf="compile->runtime"/>
<dependency org="org.hibernate" name="com.springsource.org.hibernate.ejb" rev="3.3.1.ga" conf="compile->runtime"/>
<dependency org="org.hsqldb" name="com.springsource.org.hsqldb" rev="1.8.0.9" conf="compile->runtime"/>
<dependency org="org.joda" name="com.springsource.org.joda.time" rev="1.6.0" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.aop" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.beans" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.context" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.core" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.expression" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.jdbc" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.orm" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.transaction" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework" name="org.springframework.web" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<!-- test-time only dependencies -->
<dependency org="org.junit" name="com.springsource.junit" rev="3.8.2" conf="test->compile"/>
<dependency org="org.springframework" name="org.springframework.test" rev="3.0.2.RELEASE" conf="test->compile"/>
<dependency org="org.junit" name="com.springsource.junit" rev="3.8.2" conf="test->runtime"/>
<dependency org="org.springframework" name="org.springframework.test" rev="3.0.2.RELEASE" conf="test->runtime"/>
</dependencies>

View File

@@ -63,9 +63,9 @@
<version>1.8.0.9</version>
</dependency>
<dependency>
<groupId>org.jboss.el</groupId>
<artifactId>com.springsource.org.jboss.el</artifactId>
<version>2.0.0.GA</version>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
@@ -87,6 +87,11 @@
<artifactId>org.springframework.core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.jdbc</artifactId>