This commit is contained in:
Keith Donald
2008-02-27 19:41:01 +00:00
parent 999a6ff0f3
commit 8fd993e384
10 changed files with 73 additions and 96 deletions

View File

@@ -58,7 +58,7 @@ public class SearchCriteria implements Serializable {
/**
* Decrease the current page
*/
public void prevPage() {
public void previousPage() {
page--;
}

View File

@@ -2,39 +2,34 @@
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd" start-state="enterBookingDetails">
<attribute name="description" value="The flow that handles the process of booking a hotel for a user" />
<attribute name="persistenceContext" value="true" type="boolean"/>
<persistence-context/>
<input-mapper>
<mapping source="#{id}" target="#{flowScope.id}" />
</input-mapper>
<start-state idref="enterBookingDetails"/>
<start-actions>
<evaluate-action expression="#{bookingService.findHotelById(id)}" result="#{flowScope.hotel}" />
<evaluate-action expression="#{flowHelper.createBooking(hotel, user, entityManager)}" result="#{flowScope.booking}" />
</start-actions>
<view-state id="enterBookingDetails" view="bookingForm.xhtml">
<transition on="proceed" to="confirmBooking">
<view-state id="enterBookingDetails">
<transition on="proceed" to="askForConfirmation">
<evaluate-action expression="booking.validate(messageContext)" />
</transition>
<transition on="cancel" to="cancel" />
</view-state>
<view-state id="confirmBooking" view="confirmBooking.xhtml">
<transition on="confirm" to="bookingAuthorized" />
<view-state id="reviewBooking">
<transition on="confirm" to="bookingConfirmed" />
<transition on="revise" to="enterBookingDetails" />
<transition on="cancel" to="cancel" />
<transition on="cancel" to="bookingCancelled" />
</view-state>
<end-state id="cancel" />
<end-state id="bookingAuthorized">
<attribute name="commit" value="true" type="boolean" />
</end-state>
<end-state id="bookingConfirmed" commit="true"/>
<end-state id="bookingCancelled" />
</flow>

View File

@@ -1,78 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<attribute name="description" value="The main flow of the application lets a user search for hotels to book" />
<var name="searchCriteria" class="org.springframework.webflow.samples.booking.SearchCriteria" />
<start-actions>
<evaluate-action expression="#{bookingService.findBookings(currentUser)}" result="#{flowScope.bookings}" type="dataModel" />
</start-actions>
<start-state idref="displayMain" />
<view-state id="displayMain" view="main.xhtml">
<transition on="findHotels" to="displayHotels" />
<transition on="cancelBooking" to="cancelBooking" />
</view-state>
<view-state id="displayHotels" view="displayHotels.xhtml">
<render-actions>
<evaluate-action expression="#{bookingService.findHotels(searchCriteria)}" result="#{flowScope.hotels}" type="dataModel" />
</render-actions>
<transition on="previous">
<evaluate-action expression="#{searchCriteria.prevPage()}" />
<set attribute="#{flashScope.renderIds}" value="searchResultsFragment" />
</transition>
<transition on="next">
<evaluate-action expression="#{searchCriteria.nextPage()}" />
<set attribute="#{flashScope.renderIds}" value="searchResultsFragment" />
</transition>
<transition on="selectHotel" to="displayHotel" />
<transition on="changeSearch" to="editSearchPopup" />
</view-state>
<view-state id="editSearchPopup" view="main.xhtml">
<attribute name="modal" value="true" type="boolean" />
<entry-actions>
<set attribute="#{flashScope.renderIds}" value="hotelSearchFragment" />
</entry-actions>
<transition on="findHotels" to="displayHotels" />
</view-state>
<view-state id="displayHotel" view="hotelDetails.xhtml">
<render-actions>
<set attribute="#{hotel}" value="#{hotels.selectedRow}" scope="request" />
</render-actions>
<transition on="book" to="bookHotel" />
<transition on="cancel" to="displayMain" />
</view-state>
<subflow-state id="bookHotel" flow="booking">
<attribute-mapper>
<input-mapper>
<mapping source="#{hotels.selectedRow.id}" target="#{id}" />
</input-mapper>
</attribute-mapper>
<transition on="bookingAuthorized" to="reloadCurrentUserBookings" />
<transition on="cancel" to="displayMain" />
</subflow-state>
<action-state id="cancelBooking">
<bean-action method="cancelBooking" bean="bookingService">
<method-arguments>
<argument expression="#{bookings.selectedRow}" parameter-type="long" />
</method-arguments>
</bean-action>
<transition on="success" to="reloadCurrentUserBookings" />
</action-state>
<action-state id="reloadCurrentUserBookings">
<evaluate-action expression="#{bookingService.findBookings(currentUser)}" result="#{flowScope.bookings}" type="dataModel" />
<transition on="success" to="displayMain" />
</action-state>
</flow>

View File

@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd" start-state="enterSearchCriteria">
<var name="searchCriteria" class="org.springframework.webflow.samples.booking.SearchCriteria" />
<view-state id="enterSearchCriteria">
<render-actions>
<evaluate-action expression="#{bookingService.findBookings(currentUser)}" result="#{flowScope.bookings}" type="dataModel" />
</render-actions>
<transition on="search" to="reviewHotels" />
<transition on="cancelBooking" to="cancelBooking" />
</view-state>
<view-state id="reviewHotels">
<render-actions>
<evaluate-action expression="#{bookingService.searchHotels(searchCriteria)}" result="#{flowScope.hotels}" type="dataModel" />
</render-actions>
<transition on="previous">
<evaluate-action expression="#{searchCriteria.previousPage()}" />
<render components="searchResultsFragment" />
</transition>
<transition on="next">
<evaluate-action expression="#{searchCriteria.nextPage()}" />
<render components="searchResultsFragment" />
</transition>
<transition on="select" to="reviewHotel" />
<transition on="changeSearch" to="changeSearchCriteria" />
</view-state>
<view-state id="changeSearchCriteria" view="enterSearchCriteria.xhtml" modal="true">
<entry-actions>
<render components="searchResultsFragment"/>
</entry-actions>
<transition on="search" to="reviewHotels" />
</view-state>
<view-state id="reviewHotel">
<render-actions>
<set attribute="#{requestScope.hotel}" value="#{hotels.selectedRow}" />
</render-actions>
<transition on="book" to="bookHotel" />
<transition on="cancel" to="enterSearchCriteria" />
</view-state>
<subflow-state id="bookHotel" flow="booking">
<attribute-mapper>
<input-mapper>
<mapping source="#{hotels.selectedRow.id}" target="#{id}" />
</input-mapper>
</attribute-mapper>
<transition on="bookingConfirmed" to="finish" />
<transition on="bookingCancelled" to="enterSearchCriteria" />
</subflow-state>
<end-state id="finish"/>
</flow>

View File

@@ -40,7 +40,7 @@
<!-- The registry of executable flow definitions -->
<webflow:flow-registry id="flowRegistry" flow-builder-services="facesFlowBuilderServices">
<webflow:flow-location path="/WEB-INF/flows/*/*-flow.xml" />
<webflow:flow-location path="/WEB-INF/flows/*/*.xml" />
</webflow:flow-registry>
<!-- Installs a listener that manages JPA persistence contexts for flows that require them -->