polish
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user