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 8e7875c5..6a119e70 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 @@ -15,7 +15,11 @@ import javax.persistence.ManyToOne; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; +import javax.validation.constraints.Future; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import org.hibernate.validator.constraints.NotEmpty; import org.springframework.binding.message.MessageBuilder; import org.springframework.binding.message.MessageContext; import org.springframework.binding.validation.ValidationContext; @@ -34,12 +38,17 @@ public class Booking implements Serializable { private Hotel hotel; + @NotNull private Date checkinDate; + @Future + @NotNull private Date checkoutDate; + @Pattern(regexp = "[0-9]{16}", message = "is not a 16 digit card number") private String creditCard; + @NotEmpty private String creditCardName; private int creditCardExpiryMonth; diff --git a/spring-webflow-samples/booking-faces/src/main/resources/JsfMessageResources.properties b/spring-webflow-samples/booking-faces/src/main/resources/JsfMessageResources.properties new file mode 100644 index 00000000..497baf8c --- /dev/null +++ b/spring-webflow-samples/booking-faces/src/main/resources/JsfMessageResources.properties @@ -0,0 +1,6 @@ +# +# Overrides default pattern in JSF for Bean Validation messages from "{0}" to "{1} {0}" where +# the {0} is the Bean Validation constraint message (e.g. "may not be empty") and {1} is the +# field name or the field label if defined (e.g. "First name"). +# +javax.faces.validator.BeanValidator.MESSAGE={1} {0} \ No newline at end of file diff --git a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/faces-config.xml b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/faces-config.xml index 21e273da..28932364 100644 --- a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/faces-config.xml +++ b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/faces-config.xml @@ -4,6 +4,8 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" version="2.0"> - - + + JsfMessageResources + + 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 215b9485..784d0dd0 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 @@ -13,48 +13,45 @@

-
-

${booking.hotel.name}

-
- ${booking.hotel.address} -
- ${booking.hotel.city}, ${booking.hotel.state}, ${booking.hotel.zip} -
- ${booking.hotel.country} -
-
- + +
+ ${booking.hotel.name}, + ${booking.hotel.address} + ${booking.hotel.city}, ${booking.hotel.state}, ${booking.hotel.zip} + ${booking.hotel.country} +
+
- Nightly rate: + Nightly Rate:
-
+

- +

-
+
Check In:
-
+

- +

-
-
Check Out:
-
+

- +

@@ -62,19 +59,17 @@
Room Preference:
-
+

-
-
- Smoking Preference: + Smoking:
-
+
@@ -91,7 +86,7 @@
Amenities:
-
+
@@ -103,27 +98,21 @@ -->
- Credit Card #: + Credit Card Number:
-
+

- - - +

-
-
Credit Card Name:
-
+

- - - - + +

@@ -131,11 +120,11 @@
Expiration Date:
-
+

- +