This commit is contained in:
Keith Donald
2008-09-05 20:10:14 +00:00
parent 8ac1cbeaba
commit 227b4a0276
4 changed files with 24 additions and 29 deletions

View File

@@ -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;

View File

@@ -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();