From dada0b2ef479da0cb92f6ce0fa149d3640e8c611 Mon Sep 17 00:00:00 2001 From: Scott Andrews Date: Wed, 13 Aug 2008 14:22:28 +0000 Subject: [PATCH] http://jira.springframework.org/browse/SWF-834 Sample apps should demonstrate collection and enum binding --- .../webflow/samples/booking/Amenity.java | 5 +++++ .../webflow/samples/booking/Booking.java | 11 ++++++++++ .../flows/booking/enterBookingDetails.xhtml | 12 ++++++++++ .../webflow/samples/booking/Amenity.java | 5 +++++ .../webflow/samples/booking/Booking.java | 12 ++++++++++ .../webapp/WEB-INF/hotels/booking/booking.xml | 3 ++- .../WEB-INF/hotels/booking/bookingForm.jsp | 22 ++++++++++++++++++- 7 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 spring-webflow-samples/booking-faces/src/main/java/org/springframework/webflow/samples/booking/Amenity.java create mode 100644 spring-webflow-samples/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Amenity.java diff --git a/spring-webflow-samples/booking-faces/src/main/java/org/springframework/webflow/samples/booking/Amenity.java b/spring-webflow-samples/booking-faces/src/main/java/org/springframework/webflow/samples/booking/Amenity.java new file mode 100644 index 00000000..9b1c2255 --- /dev/null +++ b/spring-webflow-samples/booking-faces/src/main/java/org/springframework/webflow/samples/booking/Amenity.java @@ -0,0 +1,5 @@ +package org.springframework.webflow.samples.booking; + +public enum Amenity { + OCEAN_VIEW, LATE_CHECKOUT, MINIBAR; +} diff --git a/spring-webflow-samples/booking-faces/src/main/java/org/springframework/webflow/samples/booking/Booking.java b/spring-webflow-samples/booking-faces/src/main/java/org/springframework/webflow/samples/booking/Booking.java index 333c0cfb..9b153f2a 100755 --- a/spring-webflow-samples/booking-faces/src/main/java/org/springframework/webflow/samples/booking/Booking.java +++ b/spring-webflow-samples/booking-faces/src/main/java/org/springframework/webflow/samples/booking/Booking.java @@ -49,6 +49,8 @@ public class Booking implements Serializable { private int beds; + private Amenity amenities; + public Booking() { } @@ -178,6 +180,15 @@ public class Booking implements Serializable { this.creditCardExpiryYear = creditCardExpiryYear; } + @Transient + public Amenity getAmenities() { + return amenities; + } + + public void setAmenities(Amenity amenities) { + this.amenities = amenities; + } + public void validateEnterBookingDetails(MessageContext context) { if (checkinDate.before(today())) { context.addMessage(new MessageBuilder().error().source("checkinDate").code( diff --git a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml index 2e3ebfda..c533c4ae 100644 --- a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml +++ b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml @@ -89,6 +89,18 @@ +
+
+ Amenities: +
+
+ + + + + +
+
Credit Card #: diff --git a/spring-webflow-samples/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Amenity.java b/spring-webflow-samples/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Amenity.java new file mode 100644 index 00000000..9b1c2255 --- /dev/null +++ b/spring-webflow-samples/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Amenity.java @@ -0,0 +1,5 @@ +package org.springframework.webflow.samples.booking; + +public enum Amenity { + OCEAN_VIEW, LATE_CHECKOUT, MINIBAR; +} diff --git a/spring-webflow-samples/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Booking.java b/spring-webflow-samples/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Booking.java index 26adfcd4..75c0dbf2 100755 --- a/spring-webflow-samples/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Booking.java +++ b/spring-webflow-samples/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Booking.java @@ -5,6 +5,7 @@ import java.math.BigDecimal; import java.text.DateFormat; import java.util.Calendar; import java.util.Date; +import java.util.Set; import javax.persistence.Basic; import javax.persistence.Entity; @@ -46,6 +47,8 @@ public class Booking implements Serializable { private int beds; + private Set amenities; + public Booking() { Calendar calendar = Calendar.getInstance(); setCheckinDate(calendar.getTime()); @@ -176,6 +179,15 @@ public class Booking implements Serializable { this.creditCardExpiryYear = creditCardExpiryYear; } + @Transient + public Set getAmenities() { + return amenities; + } + + public void setAmenities(Set amenities) { + this.amenities = amenities; + } + public void validateEnterBookingDetails(MessageContext context) { if (checkinDate.before(today())) { context.addMessage(new MessageBuilder().error().source("checkinDate").code( diff --git a/spring-webflow-samples/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/booking.xml b/spring-webflow-samples/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/booking.xml index 4da48376..439e0c07 100644 --- a/spring-webflow-samples/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/booking.xml +++ b/spring-webflow-samples/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/booking.xml @@ -22,7 +22,8 @@ - + + diff --git a/spring-webflow-samples/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/bookingForm.jsp b/spring-webflow-samples/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/bookingForm.jsp index 6f112f78..238ba477 100644 --- a/spring-webflow-samples/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/bookingForm.jsp +++ b/spring-webflow-samples/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/bookingForm.jsp @@ -89,7 +89,27 @@ widgetModule : "dijit.form.CheckBox", widgetAttrs : { value : false }})); - +
+
+
+
+ Amenities: +
+
+
    +
  • +
  • +
  • +
+