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();
|
||||
|
||||
@@ -10,12 +10,6 @@
|
||||
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
|
||||
</application>
|
||||
|
||||
<managed-bean>
|
||||
<managed-bean-name>bookingController</managed-bean-name>
|
||||
<managed-bean-class>org.springframework.webflow.samples.booking.jsf.BookingController</managed-bean-class>
|
||||
<managed-bean-scope>request</managed-bean-scope>
|
||||
</managed-bean>
|
||||
|
||||
<managed-bean>
|
||||
<managed-bean-name>searchController</managed-bean-name>
|
||||
<managed-bean-class>org.springframework.webflow.samples.booking.jsf.SearchController</managed-bean-class>
|
||||
@@ -39,7 +33,7 @@
|
||||
<value>#{param.id}</value>
|
||||
</managed-property>
|
||||
</managed-bean>
|
||||
|
||||
|
||||
<managed-bean>
|
||||
<managed-bean-name>bookingController</managed-bean-name>
|
||||
<managed-bean-class>org.springframework.webflow.samples.booking.jsf.BookingController</managed-bean-class>
|
||||
@@ -57,14 +51,8 @@
|
||||
<value>#{booking}</value>
|
||||
</managed-property>
|
||||
</managed-bean>
|
||||
|
||||
<managed-bean>
|
||||
<managed-bean-name>searchCriteria</managed-bean-name>
|
||||
<managed-bean-class>org.springframework.webflow.samples.booking.SearchCriteria</managed-bean-class>
|
||||
<managed-bean-scope>request</managed-bean-scope>
|
||||
</managed-bean>
|
||||
|
||||
<navigation-rule>
|
||||
<navigation-rule>
|
||||
<from-view-id>/main/enterSearchCriteria.xhtml</from-view-id>
|
||||
<navigation-case>
|
||||
<from-outcome>reviewHotels</from-outcome>
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
http://www.springframework.org/schema/tx
|
||||
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
|
||||
|
||||
<!-- Activates annotation-based bean configuration -->
|
||||
<context:annotation-config />
|
||||
|
||||
<!-- Scans for application @Components to deploy -->
|
||||
<context:component-scan base-package="org.springframework.webflow.samples.booking" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user