further polishing
This commit is contained in:
@@ -20,7 +20,7 @@ public class MainActions extends MultiAction {
|
||||
}
|
||||
|
||||
public Event initCurrentUser(RequestContext context) {
|
||||
User user = new User("springer", "springrocks", "Spring User");
|
||||
User user = new User("Springer", "springrocks", "Spring User");
|
||||
context.getConversationScope().put("user", user);
|
||||
return success();
|
||||
}
|
||||
@@ -28,23 +28,15 @@ public class MainActions extends MultiAction {
|
||||
public Event findCurrentUserBookings(RequestContext context) {
|
||||
User user = (User) context.getConversationScope().get("user");
|
||||
List<Booking> bookings = bookingService.findBookings(user.getName());
|
||||
if (bookings != null) {
|
||||
context.getFlowScope().put("bookings", new SerializableListDataModel(bookings));
|
||||
} else {
|
||||
context.getFlowScope().put("bookings", null);
|
||||
}
|
||||
context.getFlowScope().put("bookings", new SerializableListDataModel(bookings));
|
||||
return success();
|
||||
}
|
||||
|
||||
public Event findHotels(RequestContext context) {
|
||||
SearchCriteria search = (SearchCriteria) context.getFlowScope().get("hotelSearch");
|
||||
SearchCriteria search = (SearchCriteria) context.getFlowScope().get("searchCriteria");
|
||||
List<Hotel> hotels = bookingService
|
||||
.findHotels(search.getSearchString(), search.getPageSize(), search.getPage());
|
||||
if (hotels != null) {
|
||||
context.getFlowScope().put("hotels", new SerializableListDataModel(hotels));
|
||||
} else {
|
||||
context.getFlowScope().put("hotels", null);
|
||||
}
|
||||
context.getFlowScope().put("hotels", new SerializableListDataModel(hotels));
|
||||
return success();
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<ref bean="entityManagerFactory"/>
|
||||
</constructor-arg>
|
||||
<constructor-arg>
|
||||
<ref bean="txManager"/>
|
||||
<ref bean="transactionManager"/>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<bean id="validateBookingAction" class="org.springframework.webflow.samples.booking.web.booking.ValidateBookingAction"/>
|
||||
<bean id="validateBookingAction" class="org.springframework.webflow.samples.booking.flow.booking.ValidateBookingAction"/>
|
||||
|
||||
</beans>
|
||||
@@ -4,62 +4,63 @@
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/webflow
|
||||
http://www.springframework.org/schema/webflow/spring-webflow-1.0.xsd">
|
||||
|
||||
<attribute name="persistenceContext" value="true"/>
|
||||
<attribute name="persistenceContext" value="true" />
|
||||
|
||||
<input-mapper>
|
||||
<input-attribute name="id" scope="flow"/>
|
||||
<input-attribute name="id" scope="flow" />
|
||||
</input-mapper>
|
||||
|
||||
<start-actions>
|
||||
<bean-action method="findHotelById" bean="bookingService">
|
||||
<method-arguments>
|
||||
<argument expression="id"/>
|
||||
</method-arguments>
|
||||
<method-result name="hotel" scope="flow"/>
|
||||
</bean-action>
|
||||
</start-actions>
|
||||
|
||||
<start-state idref="displayHotel"/>
|
||||
|
||||
<view-state id="displayHotel" view="/flows/booking/hotelDetails.xhtml">
|
||||
<transition on="book" to="bookHotel"/>
|
||||
<transition on="cancel" to="cancel"/>
|
||||
<view-state id="displayHotel" view="/flow/booking/hotelDetails.xhtml">
|
||||
<render-actions>
|
||||
<bean-action method="findHotelById" bean="bookingService">
|
||||
<method-arguments>
|
||||
<argument expression="id" />
|
||||
</method-arguments>
|
||||
<method-result name="hotel" scope="flow" />
|
||||
</bean-action>
|
||||
</render-actions>
|
||||
<transition on="book" to="bookHotel" />
|
||||
<transition on="cancel" to="cancel" />
|
||||
</view-state>
|
||||
|
||||
<action-state id="bookHotel">
|
||||
<bean-action bean="bookingService" method="bookHotel">
|
||||
<bean-action method="bookHotel" bean="bookingService">
|
||||
<method-arguments>
|
||||
<argument expression="hotel"/>
|
||||
<argument expression="user"/>
|
||||
<argument expression="hotel" />
|
||||
<argument expression="user" />
|
||||
</method-arguments>
|
||||
<method-result name="booking" scope="flow"/>
|
||||
<method-result name="booking" scope="flow" />
|
||||
</bean-action>
|
||||
<transition to="enterBookingDetails"/>
|
||||
<transition to="enterBookingDetails" />
|
||||
</action-state>
|
||||
|
||||
<view-state id="enterBookingDetails" view="/flows/booking/bookDetails.xhtml">
|
||||
<transition on="reviewDetails" to="validateBooking"/>
|
||||
<transition on="cancel" to="cancel"/>
|
||||
<view-state id="enterBookingDetails" view="/flow/booking/bookingForm.xhtml">
|
||||
<transition on="reviewDetails" to="validateBooking" />
|
||||
<transition on="cancel" to="cancel" />
|
||||
</view-state>
|
||||
|
||||
<action-state id="validateBooking">
|
||||
<action bean="validateBookingAction"/>
|
||||
<transition on="success" to="confirmBooking"/>
|
||||
<transition on="error" to="enterBookingDetails"/>
|
||||
<action bean="validateBookingAction" />
|
||||
<transition on="success" to="confirmBooking" />
|
||||
<transition on="error" to="enterBookingDetails" />
|
||||
</action-state>
|
||||
|
||||
<view-state id="confirmBooking" view="/flows/booking/confirmBooking.xhtml">
|
||||
<transition on="confirm" to="authorizeBooking"/>
|
||||
<transition on="revise" to="enterBookingDetails"/>
|
||||
<transition on="cancel" to="cancel"/>
|
||||
<view-state id="confirmBooking" view="/flow/booking/confirmBooking.xhtml">
|
||||
<transition on="confirm" to="bookingAuthorized" />
|
||||
<transition on="revise" to="enterBookingDetails" />
|
||||
<transition on="cancel" to="cancel" />
|
||||
</view-state>
|
||||
|
||||
<end-state id="cancel">
|
||||
<attribute name="commit" value="false" type="boolean"/>
|
||||
<attribute name="commit" value="false" type="boolean" />
|
||||
</end-state>
|
||||
|
||||
<end-state id="authorizeBooking">
|
||||
<attribute name="commit" value="true" type="boolean"/>
|
||||
<end-state id="bookingAuthorized">
|
||||
<attribute name="commit" value="true" type="boolean" />
|
||||
</end-state>
|
||||
|
||||
<import resource="booking-beans.xml"/>
|
||||
|
||||
</flow>
|
||||
@@ -49,7 +49,7 @@
|
||||
<div class="section">
|
||||
<h:form id="hotel">
|
||||
<fieldset class="buttonBox">
|
||||
<h:commandButton id="bookHotel" action="bookHotel" value="Book Hotel"/> 
|
||||
<h:commandButton id="book" action="book" value="Book Hotel"/> 
|
||||
<h:commandButton id="cancel" action="cancel" value="Back to Search"/>
|
||||
</fieldset>
|
||||
</h:form>
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
</span>
|
||||
<h1>Search Hotels</h1>
|
||||
<fieldset>
|
||||
<h:inputText id="searchString" value="#{hotelSearch.searchString}" style="width: 165px; height: 15px;"/> 
|
||||
<h:commandButton id="findHotels" value="Find Hotels" actionListener="#{hotelSearch.findHotelsListener}" action="findHotels"/>
|
||||
<h:inputText id="searchString" value="#{searchCriteria.searchString}" style="width: 165px; height: 15px;"/> 
|
||||
<h:commandButton id="findHotels" value="Find Hotels" actionListener="#{searchCriteria.findHotelsListener}" action="findHotels"/>
|
||||
<br/>
|
||||
<h:outputLabel for="pageSize">Maximum results:</h:outputLabel> 
|
||||
<h:selectOneMenu value="#{hotelSearch.pageSize}" id="pageSize">
|
||||
<h:selectOneMenu value="#{searchCriteria.pageSize}" id="pageSize">
|
||||
<f:selectItem itemLabel="5" itemValue="5"/>
|
||||
<f:selectItem itemLabel="10" itemValue="10"/>
|
||||
<f:selectItem itemLabel="20" itemValue="20"/>
|
||||
@@ -53,10 +53,10 @@
|
||||
</h:column>
|
||||
</h:dataTable>
|
||||
<div class="prev">
|
||||
<h:commandLink id="prevPageLink" value="Previous results" actionListener="#{hotelSearch.prevPageListener}" action="findHotels" rendered="#{hotelSearch.page > 0}"/>
|
||||
<h:commandLink id="prevPageLink" value="Previous results" actionListener="#{searchCriteria.prevPageListener}" action="findHotels" rendered="#{hotelSearch.page > 0}"/>
|
||||
</div>
|
||||
<div class="next">
|
||||
<h:commandLink id="nextPageLink" value="More results" actionListener="#{hotelSearch.nextPageListener}" action="findHotels" rendered="#{hotels != null and hotels.rowCount == hotelSearch.pageSize}"/>
|
||||
<h:commandLink id="nextPageLink" value="More results" actionListener="#{searchCriteria.nextPageListener}" action="findHotels" rendered="#{hotels != null and hotels.rowCount == hotelSearch.pageSize}"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/webflow
|
||||
http://www.springframework.org/schema/webflow/spring-webflow-1.0.xsd">
|
||||
|
||||
<var name="searchCriteria" class="org.springframework.webflow.samples.booking.web.SearchCriteria" scope="flow" />
|
||||
<var name="searchCriteria" class="org.springframework.webflow.samples.booking.flow.main.SearchCriteria" scope="flow" />
|
||||
|
||||
<start-actions>
|
||||
<action method="initCurrentUser" bean="mainActions" />
|
||||
@@ -13,24 +13,25 @@
|
||||
|
||||
<start-state idref="displayMain"/>
|
||||
|
||||
<view-state id="displayMain" view="/flows/main/main.xhtml">
|
||||
<view-state id="displayMain" view="/flow/main/main.xhtml">
|
||||
<transition on="findHotels" to="findHotels" />
|
||||
<transition on="selectHotel" to="bookHotel" />
|
||||
<transition on="cancelBooking" to="cancelBooking" />
|
||||
</view-state>
|
||||
|
||||
<action-state id="findHotels">
|
||||
<action bean="searchAction" method="findHotels" />
|
||||
<action method="findHotels" bean="mainActions" />
|
||||
<transition on="success" to="displayMain" />
|
||||
</action-state>
|
||||
|
||||
<subflow-state id="bookHotel" flow="booking-flow">
|
||||
<subflow-state id="bookHotel" flow="booking">
|
||||
<attribute-mapper>
|
||||
<input-mapper>
|
||||
<mapping source="param.hotelId" target="id" from="string" to="long"/>
|
||||
<mapping source="param.hotelId" target="id" from="string" to="long" />
|
||||
</input-mapper>
|
||||
</attribute-mapper>
|
||||
<transition on="*" to="findBookings"/>
|
||||
<transition on="bookingAuthorized" to="reloadCurrentUserBookings" />
|
||||
<transition on="cancel" to="displayMain" />
|
||||
</subflow-state>
|
||||
|
||||
<action-state id="cancelBooking">
|
||||
@@ -43,8 +44,10 @@
|
||||
</action-state>
|
||||
|
||||
<action-state id="reloadCurrentUserBookings">
|
||||
<action bean="searchAction" method="findCurrentUserBookings" />
|
||||
<action method="findCurrentUserBookings" bean="mainActions" />
|
||||
<transition on="success" to="displayMain" />
|
||||
</action-state>
|
||||
|
||||
|
||||
<import resource="main-beans.xml" />
|
||||
|
||||
</flow>
|
||||
Reference in New Issue
Block a user