http://jira.springframework.org/browse/SWF-834 Sample apps should demonstrate collection and enum binding
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package org.springframework.webflow.samples.booking;
|
||||
|
||||
public enum Amenity {
|
||||
OCEAN_VIEW, LATE_CHECKOUT, MINIBAR;
|
||||
}
|
||||
@@ -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(
|
||||
|
||||
@@ -89,6 +89,18 @@
|
||||
</h:selectOneRadio>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<h:outputLabel for="amenities">Amenities:</h:outputLabel>
|
||||
</div>
|
||||
<div class="input">
|
||||
<h:selectOneRadio id="amenities" value="#{booking.amenities}" layout="pageDirection">
|
||||
<f:selectItem itemValue="OCEAN_VIEW" itemLabel="Ocean View" />
|
||||
<f:selectItem itemValue="LATE_CHECKOUT" itemLabel="Late Checkout" />
|
||||
<f:selectItem itemValue="MINIBAR" itemLabel="Minibar" />
|
||||
</h:selectOneRadio>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<h:outputLabel for="creditCard">Credit Card #:</h:outputLabel>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package org.springframework.webflow.samples.booking;
|
||||
|
||||
public enum Amenity {
|
||||
OCEAN_VIEW, LATE_CHECKOUT, MINIBAR;
|
||||
}
|
||||
@@ -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<Amenity> 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<Amenity> getAmenities() {
|
||||
return amenities;
|
||||
}
|
||||
|
||||
public void setAmenities(Set<Amenity> amenities) {
|
||||
this.amenities = amenities;
|
||||
}
|
||||
|
||||
public void validateEnterBookingDetails(MessageContext context) {
|
||||
if (checkinDate.before(today())) {
|
||||
context.addMessage(new MessageBuilder().error().source("checkinDate").code(
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
<binding property="creditCard" required="true" />
|
||||
<binding property="creditCardName" required="true" />
|
||||
<binding property="creditCardExpiryMonth" required="true" />
|
||||
<binding property="creditCardExpiryYear" required="true" />
|
||||
<binding property="creditCardExpiryYear" required="true" />
|
||||
<binding property="amenities" required="false" />
|
||||
</binder>
|
||||
<transition on="proceed" to="reviewBooking" />
|
||||
<transition on="cancel" to="cancel" bind="false" />
|
||||
|
||||
@@ -89,7 +89,27 @@
|
||||
widgetModule : "dijit.form.CheckBox",
|
||||
widgetAttrs : { value : false }}));
|
||||
</script>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
Amenities:
|
||||
</div>
|
||||
<div id="amenities" class="input">
|
||||
<ul>
|
||||
<li><form:checkbox path="amenities" value="OCEAN_VIEW" label="Ocean View" /></li>
|
||||
<li><form:checkbox path="amenities" value="LATE_CHECKOUT" label="Late Checkout" /></li>
|
||||
<li><form:checkbox path="amenities" value="MINIBAR" label="Minibar" /></li>
|
||||
</ul>
|
||||
<script type="text/javascript">
|
||||
dojo.query('#amenities input').forEach(function(element){
|
||||
Spring.addDecoration(new Spring.ElementDecoration({
|
||||
elementId: element.id,
|
||||
widgetType : "dijit.form.CheckBox",
|
||||
widgetAttrs : { checked : element.checked }
|
||||
}));
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
|
||||
Reference in New Issue
Block a user