2.0.4 improvements: development mode, flow model parent registry fix, flow handler mapping, improved sample
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
</webflow:flow-registry>
|
||||
|
||||
<!-- Configures the Spring Web Flow JSF integration -->
|
||||
<faces:flow-builder-services id="facesFlowBuilderServices" />
|
||||
<faces:flow-builder-services id="facesFlowBuilderServices" development="true" />
|
||||
|
||||
<!-- Installs a listener that manages JPA persistence contexts for flows that require them -->
|
||||
<bean id="jpaFlowExecutionListener" class="org.springframework.webflow.persistence.JpaFlowExecutionListener">
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -21,29 +21,27 @@ public class HotelsController {
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public List<Booking> index(SearchCriteria searchCriteria, Principal currentUser) {
|
||||
public void index(SearchCriteria searchCriteria, Principal currentUser, Model model) {
|
||||
if (currentUser != null) {
|
||||
return bookingService.findBookings(currentUser.getName());
|
||||
} else {
|
||||
return null;
|
||||
List<Booking> booking = bookingService.findBookings(currentUser.getName());
|
||||
model.addAttribute(booking);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public @ModelAttribute("hotels")
|
||||
List<Hotel> search(SearchCriteria criteria) {
|
||||
return bookingService.findHotels(criteria);
|
||||
public String search(SearchCriteria criteria, Model model) {
|
||||
List<Hotel> hotels = bookingService.findHotels(criteria);
|
||||
model.addAttribute(hotels);
|
||||
return "hotels/search";
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public Hotel show(@RequestParam("id")
|
||||
Long id) {
|
||||
public Hotel show(@RequestParam("id") Long id) {
|
||||
return bookingService.findHotelById(id);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public String deleteBooking(@RequestParam("id")
|
||||
Long id) {
|
||||
public String deleteBooking(@RequestParam("id") Long id) {
|
||||
bookingService.cancelBooking(id);
|
||||
return "redirect:index";
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
|
||||
<!-- The registry of executable flow definitions -->
|
||||
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
|
||||
<webflow:flow-location path="/WEB-INF/hotels/booking/booking.xml" />
|
||||
<webflow:flow-location id="hotels/booking" path="/WEB-INF/hotels/booking/booking.xml" />
|
||||
</webflow:flow-registry>
|
||||
|
||||
|
||||
<!-- Plugs in a custom creator for Web Flow views -->
|
||||
<webflow:flow-builder-services id="flowBuilderServices" view-factory-creator="mvcViewFactoryCreator" conversion-service="conversionService"/>
|
||||
<webflow:flow-builder-services id="flowBuilderServices" view-factory-creator="mvcViewFactoryCreator" conversion-service="conversionService" development="true" />
|
||||
|
||||
<!-- Configures Web Flow to use Tiles to create views for rendering; Tiles allows for applying consistent layouts to your views -->
|
||||
<bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
|
||||
|
||||
@@ -4,58 +4,45 @@
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
|
||||
|
||||
<!-- URL to flow mapping rules -->
|
||||
<bean id="flowMappings" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
|
||||
<property name="mappings">
|
||||
<value>
|
||||
/hotels/booking=bookingFlowHandler
|
||||
</value>
|
||||
</property>
|
||||
<property name="order" value="0"/>
|
||||
|
||||
<!-- Maps request paths to flows in the flowRegistry; e.g. a path of /hotels/booking looks for a flow with id "hotels/booking" -->
|
||||
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
|
||||
<property name="order" value="0" />
|
||||
</bean>
|
||||
|
||||
<!-- Maps request paths to @Controller classes; e.g. a path of /hotels looks for a controller named HotelsController -->
|
||||
<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
|
||||
<property name="order" value="1" />
|
||||
<property name="defaultHandler">
|
||||
<!-- If no @Controller match, map path to a view to render; e.g. the "/intro" path would map to the view named "intro" -->
|
||||
<bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Controls access to the hotel booking flow -->
|
||||
<bean id="bookingFlowHandler" class="org.springframework.webflow.samples.booking.BookingFlowHandler" />
|
||||
|
||||
<!-- Enables convention-based request URL mapping to @Controllers e.g. /hotels/* maps to HotelsController -->
|
||||
<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
|
||||
<property name="order" value="1"/>
|
||||
</bean>
|
||||
|
||||
<!-- Maps all other request URLs to views -->
|
||||
<bean id="viewMappings" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
|
||||
<property name="defaultHandler">
|
||||
<!-- Selects view names to render based on the request URI: e.g. the "/intro" URL would map to the view named "intro" -->
|
||||
<bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
|
||||
</property>
|
||||
<property name="order" value="2"/>
|
||||
</bean>
|
||||
|
||||
<!-- Configures the Tiles layout system -->
|
||||
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
|
||||
<property name="definitions">
|
||||
<list>
|
||||
<value>/WEB-INF/layouts/layouts.xml</value>
|
||||
<value>/WEB-INF/views.xml</value>
|
||||
<value>/WEB-INF/hotels/views.xml</value>
|
||||
<value>/WEB-INF/hotels/booking/views.xml</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Resolves views by delegating to the Tiles layout system; a view name to resolve is treated as the name of a tiles definition -->
|
||||
|
||||
<!-- Resolves logical view names returned by Controllers to Tiles; a view name to resolve is treated as the name of a tiles definition -->
|
||||
<bean id="tilesViewResolver" class="org.springframework.js.ajax.AjaxUrlBasedViewResolver">
|
||||
<property name="viewClass" value="org.springframework.webflow.mvc.view.FlowAjaxTilesView"/>
|
||||
</bean>
|
||||
|
||||
<!-- Enables annotated POJO @Controllers -->
|
||||
|
||||
<!-- Configures the Tiles layout system -->
|
||||
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
|
||||
<property name="definitions">
|
||||
<list>
|
||||
<value>/WEB-INF/layouts/layouts.xml</value>
|
||||
<value>/WEB-INF/views.xml</value>
|
||||
<value>/WEB-INF/hotels/views.xml</value>
|
||||
<value>/WEB-INF/hotels/booking/views.xml</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Dispatches requests mapped to POJO @Controller implementations -->
|
||||
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
|
||||
|
||||
<!-- Enables plain Controllers -->
|
||||
<!-- Dispatches requests mapped to org.springframework.web.servlet.mvc.Controller implementations -->
|
||||
<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
|
||||
|
||||
<!-- Enables FlowHandlers -->
|
||||
<!-- Dispatches requests mapped to flows -->
|
||||
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
|
||||
<property name="flowExecutor" ref="flowExecutor"/>
|
||||
</bean>
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<transition on="cancel" to="cancel" />
|
||||
</view-state>
|
||||
|
||||
<end-state id="bookingConfirmed" commit="true" />
|
||||
<end-state id="bookingConfirmed" commit="true" view="externalRedirect:servletRelative:/hotels/index"/>
|
||||
|
||||
<end-state id="cancel" />
|
||||
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
booking.checkinDate.typeMismatch=The Check In Date must be in the format dd/mm/yy
|
||||
booking.checkinDate.beforeToday=The Check In Date must be a future date
|
||||
booking.checkinDate.required=The check in date is required
|
||||
booking.checkinDate.typeMismatch=The check in date must be in the format dd/mm/yy
|
||||
booking.checkinDate.beforeToday=The check in date must be a future date
|
||||
|
||||
booking.checkoutDate.typeMismatch=The Check Out Date must be in the format dd/mm/yy
|
||||
booking.checkoutDate.beforeCheckinDate=The Check Out Date must be later than the Check In Date
|
||||
booking.checkoutDate.required=The check out date is required
|
||||
booking.checkoutDate.typeMismatch=The check out date must be in the format dd/mm/yy
|
||||
booking.checkoutDate.beforeCheckinDate=The check out date must be later than the check in date
|
||||
|
||||
booking.creditCard.required=The credit card must be a valid 16 digit number
|
||||
booking.creditCardName.required=The name on the credit card is required
|
||||
|
||||
required=The {0} field is required
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</script>
|
||||
</p>
|
||||
<div id="hotelResults" class="section">
|
||||
<c:if test="${not empty hotels}">
|
||||
<c:if test="${not empty hotelList}">
|
||||
<table class="summary">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -29,7 +29,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach var="hotel" items="${hotels}">
|
||||
<c:forEach var="hotel" items="${hotelList}">
|
||||
<tr>
|
||||
<td>${hotel.name}</td>
|
||||
<td>${hotel.address}</td>
|
||||
@@ -38,7 +38,7 @@
|
||||
<td><a href="show?id=${hotel.id}">View Hotel</a></td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
<c:if test="${empty hotels}">
|
||||
<c:if test="${empty hotelList}">
|
||||
<tr>
|
||||
<td colspan="5">No hotels found</td>
|
||||
</tr>
|
||||
@@ -56,7 +56,7 @@
|
||||
}));
|
||||
</script>
|
||||
</c:if>
|
||||
<c:if test="${not empty hotels && fn:length(hotels) == searchCriteria.pageSize}">
|
||||
<c:if test="${not empty hotelList && fn:length(hotelList) == searchCriteria.pageSize}">
|
||||
<a id="moreResultsLink" href="search?searchString=${searchCriteria.searchString}&pageSize=${searchCriteria.pageSize}&page=${searchCriteria.page + 1}">More Results</a>
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.AjaxEventDecoration({
|
||||
|
||||
Reference in New Issue
Block a user