diff --git a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/BookingController.java b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/BookingController.java index dc8ce4a6..b54d4b66 100644 --- a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/BookingController.java +++ b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/BookingController.java @@ -31,6 +31,7 @@ public class BookingController { public void setHotelId(Long hotelId) { if (hotelId != null && hotelId != 0 && !initialized) { + // put booking in session booking = bookingService.createBooking(hotelId, getCurrentUser()); FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("booking", booking); initialized = true; diff --git a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/SearchController.java b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/SearchController.java index 4d516b55..2f8944bc 100644 --- a/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/SearchController.java +++ b/spring-webflow-samples/jsf-booking/src/main/java/org/springframework/webflow/samples/booking/jsf/SearchController.java @@ -12,26 +12,25 @@ import org.springframework.webflow.samples.booking.SearchCriteria; public class SearchController { - private BookingService bookingService; + private SearchCriteria searchCriteria; - private SearchCriteria searchCriteria = new SearchCriteria(); + private DataModel bookings; private DataModel hotels; - private DataModel bookings; + private BookingService bookingService; public void setBookingService(BookingService bookingService) { this.bookingService = bookingService; } public SearchCriteria getSearchCriteria() { + if (searchCriteria == null) { + searchCriteria = new SearchCriteria(); + } return searchCriteria; } - public DataModel getHotels() { - return hotels; - } - public DataModel getBookings() { if (bookings == null) { // load the current user's bookings from the database @@ -40,12 +39,26 @@ public class SearchController { return bookings; } + public DataModel getHotels() { + return hotels; + } + + // from enterSearchCriteria.xhtml + public String search() { searchCriteria.resetPage(); executeSearch(); return "reviewHotels"; } + public void cancelBookingListener(ActionEvent event) { + Booking booking = (Booking) bookings.getRowData(); + bookingService.cancelBooking(booking); + ((List) bookings.getWrappedData()).remove(booking); + } + + // from reviewHotels.xhtml + public void nextListener(ActionEvent event) { searchCriteria.nextPage(); executeSearch(); @@ -56,11 +69,7 @@ public class SearchController { executeSearch(); } - public void cancelBookingListener(ActionEvent event) { - Booking booking = (Booking) bookings.getRowData(); - bookingService.cancelBooking(booking); - ((List) bookings.getWrappedData()).remove(booking); - } + // internal helpers private void executeSearch() { hotels = new ListDataModel(); diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/faces-config.xml b/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/faces-config.xml index ac3675d4..da3c88b6 100644 --- a/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/faces-config.xml +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/faces-config.xml @@ -10,12 +10,6 @@ com.sun.facelets.FaceletViewHandler - - bookingController - org.springframework.webflow.samples.booking.jsf.BookingController - request - - searchController org.springframework.webflow.samples.booking.jsf.SearchController @@ -39,7 +33,7 @@ #{param.id} - + bookingController org.springframework.webflow.samples.booking.jsf.BookingController @@ -57,14 +51,8 @@ #{booking} - - - searchCriteria - org.springframework.webflow.samples.booking.SearchCriteria - request - - + /main/enterSearchCriteria.xhtml reviewHotels diff --git a/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/web-application-config.xml b/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/web-application-config.xml index c7c97035..75264585 100644 --- a/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/web-application-config.xml +++ b/spring-webflow-samples/jsf-booking/src/main/webapp/WEB-INF/web-application-config.xml @@ -11,9 +11,6 @@ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> - - -