diff --git a/spring-webflow-samples/booking-jsf/src/main/java/org/springframework/webflow/samples/booking/flow/booking/BookingOptions.java b/spring-webflow-samples/booking-jsf/src/main/java/org/springframework/webflow/samples/booking/flow/booking/BookingOptions.java new file mode 100644 index 00000000..4c07aa3b --- /dev/null +++ b/spring-webflow-samples/booking-jsf/src/main/java/org/springframework/webflow/samples/booking/flow/booking/BookingOptions.java @@ -0,0 +1,70 @@ +package org.springframework.webflow.samples.booking.flow.booking; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import javax.faces.model.SelectItem; + +public class BookingOptions implements Serializable { + + private List bedOptions; + + private List smokingOptions; + + private List creditCardExpMonths; + + private List creditCardExpYears; + + public List getBedOptions() { + if (bedOptions == null) { + bedOptions = new ArrayList(); + bedOptions.add(new SelectItem(new Integer(1), "One king-size bed")); + bedOptions.add(new SelectItem(new Integer(2), "Two double beds")); + bedOptions.add(new SelectItem(new Integer(3), "Three beds")); + } + return bedOptions; + } + + public List getSmokingOptions() { + if (smokingOptions == null) { + smokingOptions = new ArrayList(); + smokingOptions.add(new SelectItem(Boolean.TRUE, "Smoking")); + smokingOptions.add(new SelectItem(Boolean.FALSE, "Non-Smoking")); + } + return smokingOptions; + } + + public List getCreditCardExpMonths() { + if (creditCardExpMonths == null) { + creditCardExpMonths = new ArrayList(); + creditCardExpMonths.add(new SelectItem(new Integer(1), "Jan")); + creditCardExpMonths.add(new SelectItem(new Integer(2), "Feb")); + creditCardExpMonths.add(new SelectItem(new Integer(3), "Mar")); + creditCardExpMonths.add(new SelectItem(new Integer(4), "Apr")); + creditCardExpMonths.add(new SelectItem(new Integer(5), "May")); + creditCardExpMonths.add(new SelectItem(new Integer(6), "Jun")); + creditCardExpMonths.add(new SelectItem(new Integer(7), "Jul")); + creditCardExpMonths.add(new SelectItem(new Integer(8), "Aug")); + creditCardExpMonths.add(new SelectItem(new Integer(9), "Sep")); + creditCardExpMonths.add(new SelectItem(new Integer(10), "Oct")); + creditCardExpMonths.add(new SelectItem(new Integer(11), "Nov")); + creditCardExpMonths.add(new SelectItem(new Integer(12), "Dec")); + } + return creditCardExpMonths; + } + + public List getCreditCardExpYears() { + if (creditCardExpYears == null) { + creditCardExpYears = new ArrayList(); + creditCardExpYears.add(new SelectItem(new Integer(2005), "2005")); + creditCardExpYears.add(new SelectItem(new Integer(2006), "2006")); + creditCardExpYears.add(new SelectItem(new Integer(2007), "2007")); + creditCardExpYears.add(new SelectItem(new Integer(2008), "2008")); + creditCardExpYears.add(new SelectItem(new Integer(2009), "2009")); + creditCardExpYears.add(new SelectItem(new Integer(2010), "2010")); + } + return creditCardExpYears; + } + +} diff --git a/spring-webflow-samples/booking-jsf/src/main/java/org/springframework/webflow/samples/booking/flow/main/MainActions.java b/spring-webflow-samples/booking-jsf/src/main/java/org/springframework/webflow/samples/booking/flow/main/MainActions.java index 6ba76514..07508b88 100644 --- a/spring-webflow-samples/booking-jsf/src/main/java/org/springframework/webflow/samples/booking/flow/main/MainActions.java +++ b/spring-webflow-samples/booking-jsf/src/main/java/org/springframework/webflow/samples/booking/flow/main/MainActions.java @@ -2,6 +2,7 @@ package org.springframework.webflow.samples.booking.flow.main; import java.util.List; +import org.springframework.faces.model.OneSelectionTrackingListDataModel; import org.springframework.webflow.action.MultiAction; import org.springframework.webflow.execution.Event; import org.springframework.webflow.execution.RequestContext; @@ -9,7 +10,6 @@ import org.springframework.webflow.samples.booking.app.Booking; import org.springframework.webflow.samples.booking.app.BookingService; import org.springframework.webflow.samples.booking.app.Hotel; import org.springframework.webflow.samples.booking.app.User; -import org.springframework.webflow.samples.booking.web.util.SerializableListDataModel; /** * Actions invoked by the main flow. These actions are extensions of the flow definition, called by the flow definition @@ -48,7 +48,7 @@ public class MainActions extends MultiAction { public Event findCurrentUserBookings(RequestContext context) { User user = (User) context.getConversationScope().get("user"); List bookings = bookingService.findBookings(user.getUsername()); - context.getFlowScope().put("bookings", new SerializableListDataModel(bookings)); + context.getFlowScope().put("bookings", new OneSelectionTrackingListDataModel(bookings)); return success(); } @@ -61,7 +61,7 @@ public class MainActions extends MultiAction { SearchCriteria search = (SearchCriteria) context.getFlowScope().get("searchCriteria"); List hotels = bookingService .findHotels(search.getSearchString(), search.getPageSize(), search.getPage()); - context.getFlowScope().put("hotels", new SerializableListDataModel(hotels)); + context.getFlowScope().put("hotels", new OneSelectionTrackingListDataModel(hotels)); return success(); } } diff --git a/spring-webflow-samples/booking-jsf/src/main/java/org/springframework/webflow/samples/booking/flow/main/SearchCriteria.java b/spring-webflow-samples/booking-jsf/src/main/java/org/springframework/webflow/samples/booking/flow/main/SearchCriteria.java index bdabd9e5..0f9eacad 100755 --- a/spring-webflow-samples/booking-jsf/src/main/java/org/springframework/webflow/samples/booking/flow/main/SearchCriteria.java +++ b/spring-webflow-samples/booking-jsf/src/main/java/org/springframework/webflow/samples/booking/flow/main/SearchCriteria.java @@ -1,8 +1,11 @@ package org.springframework.webflow.samples.booking.flow.main; import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; import javax.faces.event.ActionEvent; +import javax.faces.model.SelectItem; import org.springframework.webflow.samples.booking.app.BookingService; @@ -26,13 +29,18 @@ public class SearchCriteria implements Serializable { /** * The maximum page size of the Hotel result list */ - private int pageSize; + private int pageSize = 5; /** * The current page of the Hotel result list. */ private int page; + /** + * The available page size options. + */ + private List pageSizeOptions; + /** * Increase the current page */ @@ -78,4 +86,13 @@ public class SearchCriteria implements Serializable { this.page = page; } + public List getPageSizeOptions() { + if (pageSizeOptions == null) { + pageSizeOptions = new ArrayList(); + pageSizeOptions.add(new SelectItem(new Integer(5), "5")); + pageSizeOptions.add(new SelectItem(new Integer(10), "10")); + pageSizeOptions.add(new SelectItem(new Integer(20), "20")); + } + return pageSizeOptions; + } } diff --git a/spring-webflow-samples/booking-jsf/src/main/java/org/springframework/webflow/samples/booking/web/util/SerializableListDataModel.java b/spring-webflow-samples/booking-jsf/src/main/java/org/springframework/webflow/samples/booking/web/util/SerializableListDataModel.java deleted file mode 100644 index c5523ad7..00000000 --- a/spring-webflow-samples/booking-jsf/src/main/java/org/springframework/webflow/samples/booking/web/util/SerializableListDataModel.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.springframework.webflow.samples.booking.web.util; - -import java.io.Serializable; -import java.util.List; - -import javax.faces.model.DataModel; -import javax.faces.model.DataModelEvent; -import javax.faces.model.DataModelListener; - -/** - * A simple List-to-JSF-DataModel adapter that is also serializable. - */ -public class SerializableListDataModel extends DataModel implements Serializable { - - private static final long serialVersionUID = 1L; - - private int _rowIndex = -1; - - private List _data; - - public SerializableListDataModel() { - super(); - } - - /** - * Adapt the list to a data model; - * @param list the list - */ - public SerializableListDataModel(List list) { - if (list == null) - throw new NullPointerException("list"); - setWrappedData(list); - } - - public int getRowCount() { - if (_data == null) { - return -1; - } - return _data.size(); - } - - public Object getRowData() { - if (_data == null) { - return null; - } - if (!isRowAvailable()) { - throw new IllegalArgumentException("row is unavailable"); - } - return _data.get(_rowIndex); - } - - public int getRowIndex() { - return _rowIndex; - } - - public Object getWrappedData() { - return _data; - } - - public boolean isRowAvailable() { - if (_data == null) { - return false; - } - return _rowIndex >= 0 && _rowIndex < _data.size(); - } - - public void setRowIndex(int rowIndex) { - if (rowIndex < -1) { - throw new IllegalArgumentException("illegal rowIndex " + rowIndex); - } - int oldRowIndex = _rowIndex; - _rowIndex = rowIndex; - if (_data != null && oldRowIndex != _rowIndex) { - Object data = isRowAvailable() ? getRowData() : null; - DataModelEvent event = new DataModelEvent(this, _rowIndex, data); - DataModelListener[] listeners = getDataModelListeners(); - for (int i = 0; i < listeners.length; i++) { - listeners[i].rowSelected(event); - } - } - } - - public void setWrappedData(Object data) { - _data = (List) data; - int rowIndex = _data != null ? 0 : -1; - setRowIndex(rowIndex); - } - -} diff --git a/spring-webflow-samples/booking-jsf/src/main/webapp/WEB-INF/config/web-application-config.xml b/spring-webflow-samples/booking-jsf/src/main/webapp/WEB-INF/config/web-application-config.xml index a619ec64..22061198 100755 --- a/spring-webflow-samples/booking-jsf/src/main/webapp/WEB-INF/config/web-application-config.xml +++ b/spring-webflow-samples/booking-jsf/src/main/webapp/WEB-INF/config/web-application-config.xml @@ -12,6 +12,9 @@ + + + @@ -26,7 +29,7 @@ - + @@ -38,8 +41,12 @@ - - + + + + + + \ No newline at end of file diff --git a/spring-webflow-samples/booking-jsf/src/main/webapp/WEB-INF/faces-config.xml b/spring-webflow-samples/booking-jsf/src/main/webapp/WEB-INF/faces-config.xml index 8a0d7056..252d150b 100755 --- a/spring-webflow-samples/booking-jsf/src/main/webapp/WEB-INF/faces-config.xml +++ b/spring-webflow-samples/booking-jsf/src/main/webapp/WEB-INF/faces-config.xml @@ -4,6 +4,11 @@ "http://java.sun.com/dtd/web-facesconfig_1_0.dtd"> + + testBean + org.springframework.webflow.samples.booking.TestJsfBean + request + com.sun.facelets.FaceletViewHandler diff --git a/spring-webflow-samples/booking-jsf/src/main/webapp/css/booking.css b/spring-webflow-samples/booking-jsf/src/main/webapp/css/booking.css index 7c9359d8..49114ede 100644 --- a/spring-webflow-samples/booking-jsf/src/main/webapp/css/booking.css +++ b/spring-webflow-samples/booking-jsf/src/main/webapp/css/booking.css @@ -47,6 +47,12 @@ float: right; } + #content.spring form div, + #content.spring form p { + padding: 0px; + margin: 0 0 .5em 0; + } + #content.spring { width: 740px; background: #fff url(../images/bg.gif) 0 0 repeat; @@ -58,7 +64,7 @@ float: left; } - #content.spring input[type="submit"], input[type="button"] { + #content.spring input[type="submit"], input[type="button"], button { font-weight: bold; color: #fff; height: 20px; @@ -67,6 +73,25 @@ vertical-align: middle; } + #content.spring button + { + font-size: 1em; + font-family: arial,helvetica,verdana,sans-serif; + margin-top: 0pt; + margin-right: 0pt; + margin-bottom: 0pt; + margin-left: 0pt; + padding-top: 2px; + padding-right: 2px; + padding-bottom: 2px; + padding-left: 2px; + } + + #content.spring button + { + vertical-align: middle; + } + .errors { font-weight: bold; text-align: center; diff --git a/spring-webflow-samples/booking-jsf/src/main/webapp/flow/booking/booking.xml b/spring-webflow-samples/booking-jsf/src/main/webapp/flow/booking/booking.xml index adcb85f2..1e2d0e00 100755 --- a/spring-webflow-samples/booking-jsf/src/main/webapp/flow/booking/booking.xml +++ b/spring-webflow-samples/booking-jsf/src/main/webapp/flow/booking/booking.xml @@ -12,24 +12,23 @@ --> + + - + - - - - - - - - - - - - + + + + + + + + + diff --git a/spring-webflow-samples/booking-jsf/src/main/webapp/flow/booking/bookingForm.xhtml b/spring-webflow-samples/booking-jsf/src/main/webapp/flow/booking/bookingForm.xhtml index 8d5c96f5..d3523b55 100755 --- a/spring-webflow-samples/booking-jsf/src/main/webapp/flow/booking/bookingForm.xhtml +++ b/spring-webflow-samples/booking-jsf/src/main/webapp/flow/booking/bookingForm.xhtml @@ -72,9 +72,7 @@
- - - +
@@ -84,8 +82,7 @@
- - +
@@ -115,25 +112,10 @@
- - - - - - - - - - - - + - - - - - +
diff --git a/spring-webflow-samples/booking-jsf/src/main/webapp/flow/booking/hotelDetails.xhtml b/spring-webflow-samples/booking-jsf/src/main/webapp/flow/main/hotelDetails.xhtml similarity index 100% rename from spring-webflow-samples/booking-jsf/src/main/webapp/flow/booking/hotelDetails.xhtml rename to spring-webflow-samples/booking-jsf/src/main/webapp/flow/main/hotelDetails.xhtml diff --git a/spring-webflow-samples/booking-jsf/src/main/webapp/flow/main/main.xhtml b/spring-webflow-samples/booking-jsf/src/main/webapp/flow/main/main.xhtml index 4ce14a2b..0e2d4c0a 100755 --- a/spring-webflow-samples/booking-jsf/src/main/webapp/flow/main/main.xhtml +++ b/spring-webflow-samples/booking-jsf/src/main/webapp/flow/main/main.xhtml @@ -7,7 +7,7 @@ template="/template.xhtml"> - +
@@ -15,6 +15,8 @@

Search Hotels

+
+
@@ -24,52 +26,64 @@
Maximum results: - - - - - + + + + + + +
- +
- - - - - Name - #{hotel.name} - - - Address - #{hotel.address} - - - City, State - #{hotel.city}, #{hotel.state}, #{hotel.country} - - - Zip - #{hotel.zip} - - - Action - - - - - - - + + +
+ + + + Name + #{hotel.name} + + + Address + #{hotel.address} + + + City, State + #{hotel.city}, #{hotel.state}, #{hotel.country} + + + Zip + #{hotel.zip} + + + Action + + + + + + +
+
+

Current Hotel Bookings

@@ -101,12 +115,12 @@ Action - - - + +
+
diff --git a/spring-webflow-samples/booking-jsf/src/main/webapp/flow/main/main.xml b/spring-webflow-samples/booking-jsf/src/main/webapp/flow/main/main.xml index c9c9bb80..0c038640 100755 --- a/spring-webflow-samples/booking-jsf/src/main/webapp/flow/main/main.xml +++ b/spring-webflow-samples/booking-jsf/src/main/webapp/flow/main/main.xml @@ -17,7 +17,9 @@ - + + + @@ -26,10 +28,15 @@
+ + + + + - + @@ -39,7 +46,7 @@ - + @@ -50,6 +57,6 @@ - + \ No newline at end of file diff --git a/spring-webflow-samples/booking-jsf/src/main/webapp/intro.xhtml b/spring-webflow-samples/booking-jsf/src/main/webapp/intro.xhtml index 4d20d74e..4e54cec9 100755 --- a/spring-webflow-samples/booking-jsf/src/main/webapp/intro.xhtml +++ b/spring-webflow-samples/booking-jsf/src/main/webapp/intro.xhtml @@ -68,6 +68,11 @@

Start your hotel booking experience

+

+ + + +