Final polish of Ajax support.
This commit is contained in:
@@ -9,7 +9,9 @@
|
||||
<on-render>
|
||||
<evaluate expression="bookingService.findBookings(currentUser.name)" result="viewScope.bookings" result-type="dataModel" />
|
||||
</on-render>
|
||||
<transition on="search" to="reviewHotels" />
|
||||
<transition on="search" to="reviewHotels">
|
||||
<evaluate expression="searchCriteria.resetPage()"/>
|
||||
</transition>
|
||||
<transition on="cancelBooking">
|
||||
<evaluate expression="bookingService.cancelBooking(bookings.selectedRow)" />
|
||||
<render fragments="bookingsFragment"/>
|
||||
|
||||
@@ -37,12 +37,14 @@ public class HotelsController {
|
||||
}
|
||||
|
||||
@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";
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@
|
||||
</bean>
|
||||
|
||||
<!-- Resolves views by delegating to the Tiles layout system; a view name to resolve is treated as the name of a tiles definition -->
|
||||
<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
|
||||
<property name="viewClass" value="org.springframework.js.ajax.tiles2.AjaxTilesView"/>
|
||||
<bean id="tilesViewResolver" class="org.springframework.js.ajax.AjaxUrlBasedViewResolver">
|
||||
<property name="viewClass" value="org.springframework.webflow.mvc.view.FlowAjaxTilesView"/>
|
||||
</bean>
|
||||
|
||||
<!-- Enables annotated POJO @Controllers -->
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
|
||||
<form:form modelAttribute="booking">
|
||||
<fieldset>
|
||||
<div class="field">
|
||||
<div class="label">Name:</div>
|
||||
<div class="output">${booking.hotel.name}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Address:</div>
|
||||
<div class="output">${booking.hotel.address}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">City, State:</div>
|
||||
<div class="output">${booking.hotel.city}, ${booking.hotel.state}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Zip:</div>
|
||||
<div class="output">${booking.hotel.zip}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Country:</div>
|
||||
<div class="output">${booking.hotel.country}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Nightly rate:</div>
|
||||
<div class="output">
|
||||
<spring:bind path="booking.hotel.price">${status.value}</spring:bind>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<label for="checkinDate">Check In Date:</label>
|
||||
</div>
|
||||
<div class="input">
|
||||
<form:input path="checkinDate"/>
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.ElementDecoration({
|
||||
elementId : "checkinDate",
|
||||
widgetType : "dijit.form.DateTextBox",
|
||||
widgetAttrs : { value : dojo.date.locale.parse(dojo.byId("checkinDate").value, {selector : "date", datePattern : "yyyy-MM-dd"}), required : true }}));
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<label for="checkoutDate">Check Out Date:</label>
|
||||
</div>
|
||||
<div class="input">
|
||||
<form:input path="checkoutDate"/>
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.ElementDecoration({
|
||||
elementId : "checkoutDate",
|
||||
widgetType : "dijit.form.DateTextBox",
|
||||
widgetAttrs : { value : dojo.date.locale.parse(dojo.byId("checkoutDate").value, {selector : "date", datePattern : "yyyy-MM-dd"}), required : true }}));
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<label for="beds">Room Preference:</label>
|
||||
</div>
|
||||
<div class="input">
|
||||
<form:select id="beds" path="beds">
|
||||
<form:option label="One king-size bed" value="1"/>
|
||||
<form:option label="Two double beds" value="2"/>
|
||||
<form:option label="Three beds" value="3"/>
|
||||
</form:select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
Smoking Preference:
|
||||
</div>
|
||||
<div id="radio" class="input">
|
||||
<form:radiobutton id="smoking" path="smoking" label="Smoking" value="true"/>
|
||||
<form:radiobutton id="non-smoking" path="smoking" label="Non Smoking" value="false"/>
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.ElementDecoration({
|
||||
elementId : 'smoking',
|
||||
widgetType : "dijit.form.RadioButton",
|
||||
widgetModule : "dijit.form.CheckBox" }));
|
||||
Spring.addDecoration(new Spring.ElementDecoration({
|
||||
elementId : 'non-smoking',
|
||||
widgetType : "dijit.form.RadioButton",
|
||||
widgetModule : "dijit.form.CheckBox" }));
|
||||
</script>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<label for="creditCard">Credit Card #:</label>
|
||||
</div>
|
||||
<div class="input">
|
||||
<form:input path="creditCard"/>
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.ElementDecoration({
|
||||
elementId : "creditCard",
|
||||
widgetType : "dijit.form.ValidationTextBox",
|
||||
widgetAttrs : { required : true, invalidMessage : "A 16-digit credit card number is required.",
|
||||
regExp : "[0-9]{16}" }}));
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<label for="creditCardName">Credit Card Name:</label>
|
||||
</div>
|
||||
<div class="input">
|
||||
<form:input path="creditCardName" maxlength="40"/>
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.ElementDecoration({
|
||||
elementId : "creditCardName",
|
||||
widgetType : "dijit.form.ValidationTextBox",
|
||||
widgetAttrs : { required : true }}));
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<label for="creditCardExpiryMonth">Expiration Date:</label>
|
||||
</div>
|
||||
<div class="input">
|
||||
<form:select id="creditCardExpiryMonth" path="creditCardExpiryMonth">
|
||||
<form:option label="Jan" value="1"/>
|
||||
<form:option label="Feb" value="2"/>
|
||||
<form:option label="Mar" value="3"/>
|
||||
<form:option label="Apr" value="4"/>
|
||||
<form:option label="May" value="5"/>
|
||||
<form:option label="Jun" value="6"/>
|
||||
<form:option label="Jul" value="7"/>
|
||||
<form:option label="Aug" value="8"/>
|
||||
<form:option label="Sep" value="9"/>
|
||||
<form:option label="Oct" value="10"/>
|
||||
<form:option label="Nov" value="11"/>
|
||||
<form:option label="Dec" value="12"/>
|
||||
</form:select>
|
||||
<form:select path="creditCardExpiryYear">
|
||||
<form:option label="2008" value="1"/>
|
||||
<form:option label="2009" value="2"/>
|
||||
<form:option label="2010" value="3"/>
|
||||
<form:option label="2011" value="4"/>
|
||||
<form:option label="2012" value="5"/>
|
||||
</form:select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="buttonGroup">
|
||||
<input type="submit" id="proceed" name="_eventId_proceed" value="Proceed"
|
||||
onclick="Spring.remoting.submitForm('proceed', 'booking', {fragments:'messages,bookingForm'}); return false;"/> 
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.ValidateAllDecoration({elementId:'proceed', event:'onclick'}));
|
||||
</script>
|
||||
<input type="submit" name="_eventId_cancel" value="Cancel"/> 
|
||||
|
||||
</div>
|
||||
</fieldset>
|
||||
</form:form>
|
||||
@@ -1,165 +1,13 @@
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
|
||||
|
||||
<div class="section">
|
||||
<div id="heading"class="section">
|
||||
<h2>Book Hotel</h2>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<form:form id="booking" modelAttribute="booking">
|
||||
<form:errors path="*" cssClass="errors" />
|
||||
<fieldset>
|
||||
<div class="field">
|
||||
<div class="label">Name:</div>
|
||||
<div class="output">${booking.hotel.name}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Address:</div>
|
||||
<div class="output">${booking.hotel.address}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">City, State:</div>
|
||||
<div class="output">${booking.hotel.city}, ${booking.hotel.state}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Zip:</div>
|
||||
<div class="output">${booking.hotel.zip}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Country:</div>
|
||||
<div class="output">${booking.hotel.country}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Nightly rate:</div>
|
||||
<div class="output">
|
||||
<spring:bind path="booking.hotel.price">${status.value}</spring:bind>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<label for="checkinDate">Check In Date:</label>
|
||||
</div>
|
||||
<div class="input">
|
||||
<form:input path="checkinDate"/>
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.ElementDecoration({
|
||||
elementId : "checkinDate",
|
||||
widgetType : "dijit.form.DateTextBox",
|
||||
widgetAttrs : { value : dojo.date.locale.parse(dojo.byId("checkinDate").value, {selector : "date", datePattern : "yyyy-MM-dd"}), required : true }}));
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<label for="checkoutDate">Check Out Date:</label>
|
||||
</div>
|
||||
<div class="input">
|
||||
<form:input path="checkoutDate"/>
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.ElementDecoration({
|
||||
elementId : "checkoutDate",
|
||||
widgetType : "dijit.form.DateTextBox",
|
||||
widgetAttrs : { value : dojo.date.locale.parse(dojo.byId("checkoutDate").value, {selector : "date", datePattern : "yyyy-MM-dd"}), required : true }}));
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<label for="beds">Room Preference:</label>
|
||||
</div>
|
||||
<div class="input">
|
||||
<form:select id="beds" path="beds">
|
||||
<form:option label="One king-size bed" value="1"/>
|
||||
<form:option label="Two double beds" value="2"/>
|
||||
<form:option label="Three beds" value="3"/>
|
||||
</form:select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
Smoking Preference:
|
||||
</div>
|
||||
<div id="radio" class="input">
|
||||
<form:radiobutton id="smoking" path="smoking" label="Smoking" value="true"/>
|
||||
<form:radiobutton id="non-smoking" path="smoking" label="Non Smoking" value="false"/>
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.ElementDecoration({
|
||||
elementId : 'smoking',
|
||||
widgetType : "dijit.form.RadioButton",
|
||||
widgetModule : "dijit.form.CheckBox" }));
|
||||
Spring.addDecoration(new Spring.ElementDecoration({
|
||||
elementId : 'non-smoking',
|
||||
widgetType : "dijit.form.RadioButton",
|
||||
widgetModule : "dijit.form.CheckBox" }));
|
||||
</script>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<label for="creditCard">Credit Card #:</label>
|
||||
</div>
|
||||
<div class="input">
|
||||
<form:input path="creditCard"/>
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.ElementDecoration({
|
||||
elementId : "creditCard",
|
||||
widgetType : "dijit.form.ValidationTextBox",
|
||||
widgetAttrs : { required : true, invalidMessage : "A 16-digit credit card number is required.",
|
||||
regExp : "[0-9]{16}" }}));
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<label for="creditCardName">Credit Card Name:</label>
|
||||
</div>
|
||||
<div class="input">
|
||||
<form:input path="creditCardName" maxlength="40"/>
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.ElementDecoration({
|
||||
elementId : "creditCardName",
|
||||
widgetType : "dijit.form.ValidationTextBox",
|
||||
widgetAttrs : { required : true }}));
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<label for="creditCardExpiryMonth">Expiration Date:</label>
|
||||
</div>
|
||||
<div class="input">
|
||||
<form:select id="creditCardExpiryMonth" path="creditCardExpiryMonth">
|
||||
<form:option label="Jan" value="1"/>
|
||||
<form:option label="Feb" value="2"/>
|
||||
<form:option label="Mar" value="3"/>
|
||||
<form:option label="Apr" value="4"/>
|
||||
<form:option label="May" value="5"/>
|
||||
<form:option label="Jun" value="6"/>
|
||||
<form:option label="Jul" value="7"/>
|
||||
<form:option label="Aug" value="8"/>
|
||||
<form:option label="Sep" value="9"/>
|
||||
<form:option label="Oct" value="10"/>
|
||||
<form:option label="Nov" value="11"/>
|
||||
<form:option label="Dec" value="12"/>
|
||||
</form:select>
|
||||
<form:select path="creditCardExpiryYear">
|
||||
<form:option label="2008" value="1"/>
|
||||
<form:option label="2009" value="2"/>
|
||||
<form:option label="2010" value="3"/>
|
||||
<form:option label="2011" value="4"/>
|
||||
<form:option label="2012" value="5"/>
|
||||
</form:select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="buttonGroup">
|
||||
<input type="submit" id="proceed" name="_eventId_proceed" value="Proceed"/> 
|
||||
<input type="submit" name="_eventId_cancel" value="Cancel"/> 
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.ValidateAllDecoration({event : 'onclick', elementId : 'proceed'}));
|
||||
</script>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form:form>
|
||||
<div id="bookingDetails" class="section">
|
||||
<tiles:insertAttribute name="messages"/>
|
||||
<tiles:insertAttribute name="bookingForm"/>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<div id="messages">
|
||||
<form:errors path="booking.*" cssClass="errors" />
|
||||
</div>
|
||||
@@ -6,7 +6,11 @@
|
||||
<tiles-definitions>
|
||||
|
||||
<definition name="enterBookingDetails" extends="standardLayout">
|
||||
<put-attribute name="body" value="/WEB-INF/hotels/booking/enterBookingDetails.jsp" />
|
||||
<put-attribute name="body" value="details.body" />
|
||||
</definition>
|
||||
<definition name="details.body" template="/WEB-INF/hotels/booking/enterBookingDetails.jsp">
|
||||
<put-attribute name="messages" value="/WEB-INF/hotels/booking/messages.jsp" />
|
||||
<put-attribute name="bookingForm" value="/WEB-INF/hotels/booking/bookingForm.jsp" />
|
||||
</definition>
|
||||
|
||||
<definition name="reviewBooking" extends="standardLayout">
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
|
||||
|
||||
<div id="bookings" "class="section">
|
||||
<security:authorize ifAllGranted="ROLE_USER">
|
||||
<h2>Current Hotel Bookings</h2>
|
||||
|
||||
<c:if test="${empty bookings}">
|
||||
<tr>
|
||||
<td colspan="7">No bookings found</td>
|
||||
</tr>
|
||||
</c:if>
|
||||
|
||||
<c:if test="${!empty bookings}">
|
||||
<table class="summary">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Address</th>
|
||||
<th>City, State</th>
|
||||
<th>Check in Date</th>
|
||||
<th>Check out Date</th>
|
||||
<th>Confirmation Number</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach var="booking" items="${bookings}">
|
||||
<tr>
|
||||
<td>${booking.hotel.name}</td>
|
||||
<td>${booking.hotel.address}</td>
|
||||
<td>${booking.hotel.city}, ${booking.hotel.state}</td>
|
||||
<td>${booking.checkinDate}</td>
|
||||
<td>${booking.checkoutDate}</td>
|
||||
<td>${booking.id}</td>
|
||||
<td>
|
||||
<a id="cancelLink_${booking.id}" href="deleteBooking?id=${booking.id}">Cancel</a>
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.AjaxEventDecoration({
|
||||
elementId:"cancelLink_${booking.id}",
|
||||
event:"onclick",
|
||||
params: {fragments:"bookingsTable"}
|
||||
}));
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
</c:if>
|
||||
</security:authorize>
|
||||
|
||||
</div>
|
||||
@@ -1,56 +0,0 @@
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||
|
||||
<div id="hotelResults" class="section">
|
||||
<c:if test="${not empty hotels}">
|
||||
<table class="summary">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Address</th>
|
||||
<th>City, State</th>
|
||||
<th>Zip</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach var="hotel" items="${hotels}">
|
||||
<tr>
|
||||
<td>${hotel.name}</td>
|
||||
<td>${hotel.address}</td>
|
||||
<td>${hotel.city}, ${hotel.state}, ${hotel.country}</td>
|
||||
<td>${hotel.zip}</td>
|
||||
<td><a href="show?id=${hotel.id}">View Hotel</a></td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
<c:if test="${empty hotels}">
|
||||
<tr>
|
||||
<td colspan="5">No hotels found</td>
|
||||
</tr>
|
||||
</c:if>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="buttonGroup">
|
||||
<c:if test="${searchCriteria.page > 0}">
|
||||
<a id="prevResultsLink" href="search?searchString=${searchCriteria.searchString}&pageSize=${searchCriteria.pageSize}&page=${searchCriteria.page - 1}">Previous Results</a>
|
||||
<script>
|
||||
Spring.addDecoration(new Spring.AjaxEventDecoration({
|
||||
elementId: "prevResultsLink",
|
||||
event: "onclick",
|
||||
params: {fragments: "hotelResults"}
|
||||
}));
|
||||
</script>
|
||||
</c:if>
|
||||
<c:if test="${not empty hotels && fn:length(hotels) == searchCriteria.pageSize}">
|
||||
<a id="moreResultsLink" href="search?searchString=${searchCriteria.searchString}&pageSize=${searchCriteria.pageSize}&page=${searchCriteria.page + 1}">More Results</a>
|
||||
<script>
|
||||
Spring.addDecoration(new Spring.AjaxEventDecoration({
|
||||
elementId: "moreResultsLink",
|
||||
event: "onclick",
|
||||
params: {fragments: "hotelResults"}
|
||||
}));
|
||||
</script>
|
||||
</c:if>
|
||||
</div>
|
||||
</c:if>
|
||||
</div>
|
||||
@@ -0,0 +1,41 @@
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
|
||||
<form:form modelAttribute="searchCriteria" action="search" method="get">
|
||||
<div class="section">
|
||||
<span class="errors">
|
||||
<form:errors path="*"/>
|
||||
</span>
|
||||
<h2>Search Hotels</h2>
|
||||
<fieldset>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<label for="searchString">Search String:</label>
|
||||
</div>
|
||||
<div class="input">
|
||||
<form:input id="searchString" path="searchString"/>
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.ElementDecoration({
|
||||
elementId : "searchString",
|
||||
widgetType : "dijit.form.ValidationTextBox",
|
||||
widgetAttrs : { promptMessage : "Search hotels by name, address, city, or zip." }}));
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<label for="pageSize">Maximum results:</label>
|
||||
</div>
|
||||
<div class="input">
|
||||
<form:select id="pageSize" path="pageSize">
|
||||
<form:option label="5" value="5"/>
|
||||
<form:option label="10" value="10"/>
|
||||
<form:option label="20" value="20"/>
|
||||
</form:select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="buttonGroup">
|
||||
<input type="submit" value="Find Hotels" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</form:form>
|
||||
@@ -1,87 +1,5 @@
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
|
||||
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
|
||||
|
||||
<form:form modelAttribute="searchCriteria" action="search" method="get">
|
||||
<div class="section">
|
||||
<span class="errors">
|
||||
<form:errors path="*"/>
|
||||
</span>
|
||||
<h2>Search Hotels</h2>
|
||||
<fieldset>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<label for="searchString">Search String:</label>
|
||||
</div>
|
||||
<div class="input">
|
||||
<form:input id="searchString" path="searchString"/>
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.ElementDecoration({
|
||||
elementId : "searchString",
|
||||
widgetType : "dijit.form.ValidationTextBox",
|
||||
widgetAttrs : { promptMessage : "Search hotels by name, address, city, or zip." }}));
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">
|
||||
<label for="pageSize">Maximum results:</label>
|
||||
</div>
|
||||
<div class="input">
|
||||
<form:select id="pageSize" path="pageSize">
|
||||
<form:option label="5" value="5"/>
|
||||
<form:option label="10" value="10"/>
|
||||
<form:option label="20" value="20"/>
|
||||
</form:select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="buttonGroup">
|
||||
<input type="submit" value="Find Hotels" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</form:form>
|
||||
<tiles:insertAttribute name="hotelSearchForm" />
|
||||
|
||||
<security:authorize ifAllGranted="ROLE_USER">
|
||||
<div class="section">
|
||||
<h2>Current Hotel Bookings</h2>
|
||||
|
||||
<c:if test="${empty bookings}">
|
||||
<tr>
|
||||
<td colspan="7">No bookings found</td>
|
||||
</tr>
|
||||
</c:if>
|
||||
|
||||
<c:if test="${!empty bookings}">
|
||||
<table class="summary">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Address</th>
|
||||
<th>City, State</th>
|
||||
<th>Check in Date</th>
|
||||
<th>Check out Date</th>
|
||||
<th>Confirmation Number</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach var="booking" items="${bookings}">
|
||||
<tr>
|
||||
<td>${booking.hotel.name}</td>
|
||||
<td>${booking.hotel.address}</td>
|
||||
<td>${booking.hotel.city}, ${booking.hotel.state}</td>
|
||||
<td>${booking.checkinDate}</td>
|
||||
<td>${booking.checkoutDate}</td>
|
||||
<td>${booking.id}</td>
|
||||
<td>
|
||||
<a href="deleteBooking?id=${booking.id}">Cancel</a>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
</c:if>
|
||||
|
||||
</div>
|
||||
</security:authorize>
|
||||
<tiles:insertAttribute name="bookingsTable" />
|
||||
|
||||
@@ -1,8 +1,72 @@
|
||||
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||
|
||||
<div id="heading" class="section">
|
||||
<h2>Hotel Results</h2>
|
||||
</div>
|
||||
|
||||
<tiles:insertAttribute name="hotelResults" />
|
||||
<p>
|
||||
<a id="changeSearchLink" href="index?searchString=${searchCriteria.searchString}&pageSize=${searchCriteria.pageSize}">Change Search</a>
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.AjaxEventDecoration({
|
||||
elementId: "changeSearchLink",
|
||||
event: "onclick",
|
||||
popup: true,
|
||||
params: {fragments: "hotelSearchForm"}
|
||||
}));
|
||||
</script>
|
||||
</p>
|
||||
<div id="hotelResults" class="section">
|
||||
<c:if test="${not empty hotels}">
|
||||
<table class="summary">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Address</th>
|
||||
<th>City, State</th>
|
||||
<th>Zip</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach var="hotel" items="${hotels}">
|
||||
<tr>
|
||||
<td>${hotel.name}</td>
|
||||
<td>${hotel.address}</td>
|
||||
<td>${hotel.city}, ${hotel.state}, ${hotel.country}</td>
|
||||
<td>${hotel.zip}</td>
|
||||
<td><a href="show?id=${hotel.id}">View Hotel</a></td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
<c:if test="${empty hotels}">
|
||||
<tr>
|
||||
<td colspan="5">No hotels found</td>
|
||||
</tr>
|
||||
</c:if>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="buttonGroup">
|
||||
<c:if test="${searchCriteria.page > 0}">
|
||||
<a id="prevResultsLink" href="search?searchString=${searchCriteria.searchString}&pageSize=${searchCriteria.pageSize}&page=${searchCriteria.page - 1}">Previous Results</a>
|
||||
<script type="text/javascript">
|
||||
Spring.addDecoration(new Spring.AjaxEventDecoration({
|
||||
elementId: "prevResultsLink",
|
||||
event: "onclick",
|
||||
params: {fragments: "body"}
|
||||
}));
|
||||
</script>
|
||||
</c:if>
|
||||
<c:if test="${not empty hotels && fn:length(hotels) == 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({
|
||||
elementId: "moreResultsLink",
|
||||
event: "onclick",
|
||||
params: {fragments: "body"}
|
||||
}));
|
||||
</script>
|
||||
</c:if>
|
||||
</div>
|
||||
</c:if>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
<tiles-definitions>
|
||||
|
||||
<definition name="hotels/index" extends="standardLayout">
|
||||
<put-attribute name="body" value="/WEB-INF/hotels/index.jsp" />
|
||||
<put-attribute name="body" value="index.body" />
|
||||
</definition>
|
||||
<definition name="index.body" template="/WEB-INF/hotels/index.jsp">
|
||||
<put-attribute name="hotelSearchForm" value="/WEB-INF/hotels/hotelSearchForm.jsp" />
|
||||
<put-attribute name="bookingsTable" value="/WEB-INF/hotels/bookingsTable.jsp" />
|
||||
</definition>
|
||||
|
||||
<definition name="hotels/search" extends="standardLayout">
|
||||
<put-attribute name="body" value="search.body" />
|
||||
<put-attribute name="body" value="/WEB-INF/hotels/search.jsp" />
|
||||
</definition>
|
||||
|
||||
<definition name="search.body" template="/WEB-INF/hotels/search.jsp">
|
||||
<put-attribute name="hotelResults" value="/WEB-INF/hotels/hotelResults.jsp" />
|
||||
</definition>
|
||||
|
||||
<definition name="hotels/show" extends="standardLayout">
|
||||
<put-attribute name="body" value="/WEB-INF/hotels/show.jsp" />
|
||||
</definition>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>Spring Travel: Spring MVC and Web Flow Reference Application</title>
|
||||
<link type="text/css" rel="stylesheet" href="<c:url value="/resources/dijit/themes/tundra/tundra.css" />" />
|
||||
<style type="text/css" media="screen">
|
||||
@import url("<c:url value="/resources/css-framework/css/tools.css" />");
|
||||
@import url("<c:url value="/resources/css-framework/css/typo.css" />");
|
||||
@@ -15,10 +16,9 @@
|
||||
@import url("<c:url value="/resources/css-framework/css/layout.css" />");
|
||||
@import url("<c:url value="/resources/styles/booking.css" />");
|
||||
</style>
|
||||
<script type="text/javascript" src="<c:url value="/resources/spring/Spring.js" />"></script>
|
||||
<script type="text/javascript" src="<c:url value="/resources/dojo/dojo.js" />"></script>
|
||||
<script type="text/javascript" src="<c:url value="/resources/spring/Spring.js" />"></script>
|
||||
<script type="text/javascript" src="<c:url value="/resources/spring/Spring-Dojo.js" />"></script>
|
||||
<link type="text/css" rel="stylesheet" href="<c:url value="/resources/dijit/themes/tundra/tundra.css" />" />
|
||||
</head>
|
||||
<body class="tundra spring">
|
||||
<div id="page">
|
||||
|
||||
Reference in New Issue
Block a user