<!-- | |
#* Licensed to the Apache Software Foundation (ASF) under one | |
or more contributor license agreements. See the NOTICE file | |
distributed with this work for additional information | |
regarding copyright ownership. The ASF licenses this file | |
to you under the Apache License, Version 2.0 (the | |
"License"); you may not use this file except in compliance | |
with the License. You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, | |
software distributed under the License is distributed on an | |
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
KIND, either express or implied. See the License for the | |
specific language governing permissions and limitations | |
under the License.*# | |
--> | |
Demonstration of page flow design patterns. | |
<p/> | |
#if ($courseBooking) | |
<b>Course Booking Completed</b> | |
<style type="text/css"> | |
td.value { | |
border: 1px dotted gray; | |
} | |
td.title { | |
font-weight: bold; | |
background-color: #e0e0e0; | |
} | |
</style> | |
<table style="border: 1px solid gray; margin: 1em;" cellpadding="8" cellspacing="8"> | |
<tr> | |
<td class="title">Booking No.</td> | |
<td class="value">$courseBooking.id</td> | |
</tr> | |
<tr> | |
<td class="title">Booking Created</td> | |
<td class="value">$format.date($courseBooking.createdAt, "dd MMM yyyy - h:mm:ss a")</td> | |
</tr> | |
<tr> | |
<td class="title">Customer Name</td> | |
<td class="value">$customer.name</td> | |
</tr> | |
<tr> | |
<td class="title">Customer No.</td> | |
<td class="value">$customer.id</td> | |
</tr> | |
<tr> | |
<td class="title">Course Date</td> | |
<td class="value">$format.date($courseBooking.bookingDate, "dd MMM yyyy")</td> | |
</tr> | |
<tr> | |
<td class="title">Course Type</td> | |
<td class="value">$courseBooking.courseType</td> | |
</tr> | |
</table> | |
#else | |
No course booking has been made. | |
#end | |
<p/> | |
<a href="start-page.htm">Create Another Booking ?</a> | |
<p> </p> | |
The LastPage gets the booking details from a "bookingId" URL request parameter. | |
<pre class="codeJava"> | |
String bookingId = getContext().getRequest().getParameter(<span class="st">"bookingId="</span>); | |
CourseBooking courseBooking = getBookingService().findCourseBookingByID(<span class="kw">new</span> Integer(bookingId)); | |
</pre> | |
The advantage of the Post-Redirect pattern is that it will not make the POST | |
request again of the previous page even if the users does a refresh. | |
<p/> | |
To prevent users from submitting the order twice by pressing the back button, | |
the <tt>StartPage</tt> of this page flow uses a form submit check. | |
<pre class="codeJava"> | |
<span class="kw">public class</span> StartPage <span class="kw">extends</span> BorderedPage { | |
.. | |
<span class="kw">public boolean</span> onSecurityCheck() { | |
<span class="kw">return</span> form.onSubmitCheck(<span class="kw">this</span>, <span class="st">"/invalid-submit.html"</span>); | |
} | |
} | |
</pre> | |