You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pp...@apache.org on 2010/05/27 19:41:44 UTC
svn commit: r948925 - in /openjpa/trunk/openjpa-examples/openbooks/web:
cart.jsp checkout.jsp footer.jsp header.jsp intro.jsp openbooks.css
orders.jsp query.jsp search.jsp
Author: ppoddar
Date: Thu May 27 17:41:43 2010
New Revision: 948925
URL: http://svn.apache.org/viewvc?rev=948925&view=rev
Log:
JSP Page cosmetic changes: tables with known column width, Graphic buttons
Modified:
openjpa/trunk/openjpa-examples/openbooks/web/cart.jsp
openjpa/trunk/openjpa-examples/openbooks/web/checkout.jsp
openjpa/trunk/openjpa-examples/openbooks/web/footer.jsp
openjpa/trunk/openjpa-examples/openbooks/web/header.jsp
openjpa/trunk/openjpa-examples/openbooks/web/intro.jsp
openjpa/trunk/openjpa-examples/openbooks/web/openbooks.css
openjpa/trunk/openjpa-examples/openbooks/web/orders.jsp
openjpa/trunk/openjpa-examples/openbooks/web/query.jsp
openjpa/trunk/openjpa-examples/openbooks/web/search.jsp
Modified: openjpa/trunk/openjpa-examples/openbooks/web/cart.jsp
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/cart.jsp?rev=948925&r1=948924&r2=948925&view=diff
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/cart.jsp (original)
+++ openjpa/trunk/openjpa-examples/openbooks/web/cart.jsp Thu May 27 17:41:43 2010
@@ -67,17 +67,22 @@
<table>
- <caption><%= cart.getTotalCount() %> book <%= cart.getTotalCount() == 1 ? "" : "s" %> in
+ <caption><%= cart.getTotalCount() %> Book<%= cart.getTotalCount() == 1 ? "" : "s" %> in
<%= customer.getName() %>'s Shopping Cart</caption>
<thead>
<tr>
- <th>Title</th> <th>Price</th> <th>Quantity</th>
+ <th width="10em">Title</th>
+ <th width="6em">Price</th>
+ <th width="4em">Quantity</th>
</tr>
</thead>
<tfoot>
<tr>
<td><A HREF="<%= PAGE_SEARCH %>">Continue Shopping</A></td>
- <td><A HREF="<%= PAGE_CHECKOUT %>">Proceed to CheckOut</A></td>
+ <td><A HREF="<%= PAGE_CHECKOUT %>">
+ <img src="images/checkout.gif"
+ width="156px" height="27px" border="0">
+ </A></td>
</tr>
</tfoot>
<tbody>
Modified: openjpa/trunk/openjpa-examples/openbooks/web/checkout.jsp
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/checkout.jsp?rev=948925&r1=948924&r2=948925&view=diff
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/checkout.jsp (original)
+++ openjpa/trunk/openjpa-examples/openbooks/web/checkout.jsp Thu May 27 17:41:43 2010
@@ -31,7 +31,7 @@
<%@include file="header.jsp"%>
<div id="help">
-<h3>Composite Pattern and Derived Identity</h3>
+<h3>Composite Relation and Derived Identity</h3>
You have just created a
<a href="generated-html/openbook/domain/PurchaseOrder.java.html#init" type="popup">new Purchase Order
@@ -78,17 +78,26 @@
<%
OpenBookService service = (OpenBookService)session.getAttribute(KEY_SERVICE);
ShoppingCart cart = (ShoppingCart)session.getAttribute(KEY_CART);
- PurchaseOrder order = service.placeOrder(cart);
-
+ PurchaseOrder order = null;
+ if (cart.isEmpty()) {
%>
-Purchase Order ID : <%= order.getId() %> <br>
-Placed on : <%= JSPUtility.format(order.getPlacedOn()) %><br>
-
+ <jsp:forward page="<%=PAGE_SEARCH%>"/>
+<%
+ } else {
+ order = service.placeOrder(cart);
+ }
+%>
+<h3>Thank you for ordering from OpenBooks</h3>
+<p>
<table>
- <caption><%= order.getItems().size() %> items</caption>
+ <caption>Order : <%= order.getId() %> on <%= JSPUtility.format(order.getPlacedOn()) %>
+ for <%= order.getItems().size() %> Book<%= order.getItems().size() == 0 ? "" : "s" %>
+ </caption>
<thead>
<tr>
- <th>Title</th> <th>Quantity</th><th>Price</th>
+ <th width="10em">Title</th>
+ <th width="04em">Quantity</th>
+ <th width="06em">Price</th>
</tr>
</thead>
<tfoot>
Modified: openjpa/trunk/openjpa-examples/openbooks/web/footer.jsp
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/footer.jsp?rev=948925&r1=948924&r2=948925&view=diff
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/footer.jsp (original)
+++ openjpa/trunk/openjpa-examples/openbooks/web/footer.jsp Thu May 27 17:41:43 2010
@@ -22,11 +22,12 @@
<!-- ========================================================================= -->
<%@page import="org.apache.openjpa.conf.OpenJPAVersion"%>
<div id="footer">
- Running on <img src="images/openjpa-logo-small.png" height="40px"> version
- <%= OpenJPAVersion.MAJOR_RELEASE + "." + OpenJPAVersion.MINOR_RELEASE %>
- <div style="float:right;text-align: right;margin-right:1em">
- <img alt="" src="images/java_link.png" border="0"> links to Java Source Code
- </div>
+ Running on <img src="images/openjpa-logo-small.png"
+ width="100px" height="40px" border="0">
+ version <%= OpenJPAVersion.MAJOR_RELEASE + "." + OpenJPAVersion.MINOR_RELEASE %>
+ <div style="float:right;text-align: right;margin-right:1em">
+ <img alt="" src="images/java_link.png" border="0"> links to Java Source Code
+ </div>
</div>
</BODY>
</HTML>
Modified: openjpa/trunk/openjpa-examples/openbooks/web/header.jsp
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/header.jsp?rev=948925&r1=948924&r2=948925&view=diff
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/header.jsp (original)
+++ openjpa/trunk/openjpa-examples/openbooks/web/header.jsp Thu May 27 17:41:43 2010
@@ -68,13 +68,19 @@
public static String ROW_STYLE_EVEN = "even";
public static String ROW_STYLE_ODD = "odd";
+
+%>
+
%>
<!-- Header division displays the title and right-justified current user name -->
<!-- and a Shopping Cart icon for active sessions -->
<div id="header">
- <img alt="OpenBooks Logo" src="images/OpenBooks.jpg" border="0" width="25px" height="25px" />
- <A HREF=".">OpenBooks</A>: JPA 2.0 Application
+ <img alt="OpenBooks Logo" src="images/OpenBooks.jpg"
+ border="0" width="25px" height="25px"
+ align="bottom"
+ hspace="2em"/>
+ <A HREF="."><span style="font-size: 24pt">OpenBooks</span></A>
<%
Object currentUser = session.getAttribute("user");
boolean activeSession = currentUser != null;
@@ -82,7 +88,8 @@
%>
<div style="float:right;text-align: right;margin-right:1em">
<%= currentUser.toString() %>
- <A HREF="cart.jsp"><img src="images/Add2Cart.jpg" border="0" width="25px" height="25px"></A>
+ <A HREF="cart.jsp"><img src="images/Add2Cart.jpg"
+ border="0" width="25px" height="25px"></A>
</div>
<%
}
@@ -92,15 +99,15 @@
<!-- Left menu navigation displays the items based on current session status -->
<div id="left">
-
+<ul>
+ <li><a href="intro.jsp">Welcome</a></li>
<%
if (activeSession) {
%>
-<ul>
<li><a href="search.jsp">Search Books</a></li>
<li><a href="orders.jsp">View Orders</a></li>
-</ul>
-</div>
<%
}
%>
+</ul>
+</div>
Modified: openjpa/trunk/openjpa-examples/openbooks/web/intro.jsp
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/intro.jsp?rev=948925&r1=948924&r2=948925&view=diff
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/intro.jsp (original)
+++ openjpa/trunk/openjpa-examples/openbooks/web/intro.jsp Thu May 27 17:41:43 2010
@@ -54,8 +54,14 @@ corresponding Java code</a> executed on
%>
<A name="login"></A>
<form method="get" action="<%= PAGE_LOGIN %>">
- Your Name :<br> <input type="text" name="<%= KEY_USER %>" size="40"> <br>
- <input type="SUBMIT" value="Enter">
+ Your Name :<br>
+ <input type="text"
+ name="<%= KEY_USER %>"
+ size="40">
+ <p>
+ <input type="image"
+ src="images/login.gif"
+ width="111px" height="22px" border="0">
</form>
<%
}
Modified: openjpa/trunk/openjpa-examples/openbooks/web/openbooks.css
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/openbooks.css?rev=948925&r1=948924&r2=948925&view=diff
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/openbooks.css (original)
+++ openjpa/trunk/openjpa-examples/openbooks/web/openbooks.css Thu May 27 17:41:43 2010
@@ -34,13 +34,16 @@ body {
#header {
position:fixed;
+
top:0;
+
width: 100%;
height: 1.5em;
margin: 0.0em;
padding: 0.0em;
- background: #fff;
+ background: #FFFFFF;
+
z-index: 100;
border-bottom: 1px solid #999;
@@ -52,18 +55,20 @@ body {
#left {
position: fixed;
- width: 10em;
top: 5em;
+
+ width: 10em;
margin-left:0.5em;
text-align: left;
float:left;
}
#content {
-/* top: 0; */
+ top: 5em;
- width:30em;
+ width:60em;
height:20em;
+
margin-left: 10em;
margin-right: 15em;
margin-top:1.5em;
@@ -101,13 +106,22 @@ body {
table {
border-spacing:0;
+ font-size:14pt;
+}
+
+caption {
+ background-color:#006295;
+ color:#FFFFFF;
+ font-weight:bold;
}
th {
background-color:#BD2031;
text-align:center;
+ color:#FFFFFF;
}
+
tr.even {
background-color:#9BE1FB;
}
Modified: openjpa/trunk/openjpa-examples/openbooks/web/orders.jsp
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/orders.jsp?rev=948925&r1=948924&r2=948925&view=diff
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/orders.jsp (original)
+++ openjpa/trunk/openjpa-examples/openbooks/web/orders.jsp Thu May 27 17:41:43 2010
@@ -28,9 +28,11 @@
<%@page import="openbook.util.JSPUtility"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.List"%>
+<%@page import="java.util.ArrayList"%>
<%@include file="header.jsp"%>
+
<div id="help">
<h3>Optimistic semantics and Orphan Delete</h3>
@@ -56,6 +58,7 @@ are no more available.
</li>
</ul>
</div>
+
<div id="content" style="display: block">
<%
@@ -72,7 +75,10 @@ are no more available.
}
Customer customer = (Customer)session.getAttribute(KEY_USER);
- List<PurchaseOrder> orders = service.getOrders(null, customer);
+ List<PurchaseOrder> pendingOrders = service.getOrders(PurchaseOrder.Status.DELIVERED, customer);
+ List<PurchaseOrder> deliveredOrders = service.getOrders(PurchaseOrder.Status.PENDING, customer);
+ List<PurchaseOrder> orders = new ArrayList<PurchaseOrder>(pendingOrders);
+ orders.addAll(deliveredOrders);
if (orders.isEmpty()) {
%>
<%= customer.getName() %>, you have not placed any order yet.<br>
@@ -80,12 +86,22 @@ are no more available.
return;
}
%>
+
+
<table>
- <caption><%= customer.getName() %>, you have placed <%= orders.size() %> orders</caption>
+ <caption><%= customer.getName() %>, you have placed <%= orders.size() %> (
+ <%= pendingOrders.size() == 0 ? "none" : "" + pendingOrders.size()%> pending,
+ <%= deliveredOrders.size() == 0 ? " none" : " " + deliveredOrders.size()%> delivered) orders
+ </caption>
<thead>
<tr>
- <th>ID</th> <th>Total</th> <th>Placed On</th> <th>Status</th> <th>Delivered On</th> <th></th>
+ <th width="06em">ID</th>
+ <th width="04em">Total</th>
+ <th width="10em">Placed On</th>
+ <th width="08em">Status</th>
+ <th width="10em">Delivered On</th>
+ <th width="08em">Deliver</th>
</tr>
</thead>
<tfoot>
@@ -97,10 +113,10 @@ are no more available.
session.setAttribute(""+order.getId(), order);
%>
<TR class="<%= i++%2 == 0 ? ROW_STYLE_EVEN : ROW_STYLE_ODD %>">
- <TD> <A HREF="<%=
- JSPUtility.encodeURL(PAGE_ORDERS,
+ <TD> <A HREF="<%= JSPUtility.encodeURL(PAGE_ORDERS,
KEY_ACTION, ACTION_DETAILS,
- KEY_OID, order.getId()) %>"> <%= order.getId() %></A></TD>
+ KEY_OID,
+ order.getId()) %>"> <%= order.getId() %></A></TD>
<TD> <%= order.getTotal() %> </TD>
<TD> <%= JSPUtility.format(order.getPlacedOn()) %> </TD>
<TD> <%= order.getStatus() %> </TD>
@@ -114,7 +130,8 @@ are no more available.
%>
<TD> </TD>
<TD> <A HREF="<%= JSPUtility.encodeURL(PAGE_ORDERS, KEY_ACTION, ACTION_DELIVER,
- KEY_OID, order.getId()) %>">Deliver</A></TD>
+ KEY_OID, order.getId()) %>">
+ <img src="images/orders.gif" width="156px" height="27px" border="0"></A></TD>
<%
}
%>
@@ -124,31 +141,36 @@ are no more available.
%>
</tbody>
</table>
-
+<p></p>
<%
if (ACTION_DETAILS.equals(request.getParameter(KEY_ACTION))) {
String oid = request.getParameter(KEY_OID);
PurchaseOrder order = (PurchaseOrder)session.getAttribute(oid);
List<LineItem> items = order.getItems();
- if (items == null) {
- if (order.isDelivered()) {
+ if (order.isDelivered()) {
+ if (items != null && items.isEmpty()) {
%>
Order <%= order.getId() %> has been delivered. Line items of delivered orders are automatically
deleted due to orphan delete nature of Master-Details relationship.
<% } else {
%>
- Order <%= order.getId() %> has no line items. This is an implementation error because
- pending orders must have at least one line item by design.
+ Order <%= order.getId() %> has been delivered but still contains line items.
+ This is an implementation error because delivered orders must have at least one line item by design.
<%
}
} else {
%>
<table>
- <caption><%= items.size() %> line items of Order <%= order.getId() %></caption>
+ <caption>Total of <%= items.size() %> Book<%= items.size() == 0 ? "" : "s" %>
+ in Order <%= order.getId() %>
+ </caption>
<thead>
<tr>
- <th>Title</th> <th>Price</th> <th>Quantity</th> <th>Cost</th>
+ <th width="10em">Title</th>
+ <th width="06em">Price</th>
+ <th width="04em">Quantity</th>
+ <th width="06em">Cost</th>
</tr>
</thead>
<tbody>
@@ -166,7 +188,8 @@ are no more available.
}
%>
<TR>
- <TD>Total</TD><TD><%= JSPUtility.format(order.getTotal()) %></TD>
+ <TD>Total</TD><TD></TD><TD></TD>
+ <TD><%= JSPUtility.format(order.getTotal()) %></TD>
</TR>
</tbody>
</table>
Modified: openjpa/trunk/openjpa-examples/openbooks/web/query.jsp
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/query.jsp?rev=948925&r1=948924&r2=948925&view=diff
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/query.jsp (original)
+++ openjpa/trunk/openjpa-examples/openbooks/web/query.jsp Thu May 27 17:41:43 2010
@@ -32,14 +32,15 @@
<div id="help">
<h3>Query Result</h3>
- This page is displaying the result of the query specified in the previous Search page.
+ This page is displaying the result of the Criteria query specified in the previous Search page.
<ul>
<li><B>Readability</B>: Criteria query is more powerful than JPQL but hardly as readable.
JPA specification says nothing about how a Criteria Query should be displayed.
OpenJPA implementation provides a simple
<a HREF="generated-html/openbook/server/OpenBookServiceImpl.java.html#getQuery" type="popup">
- <code>toString()</code></a> method to display a query string that is quite <em>similar</em> to
- an equivalent JPQL string.
+ <code>toString()</code></a> method to display a Criteria query as a string that is quite
+ <em>similar</em> to an equivalent JPQL string. <em>Similar</em> because Criteria query can
+ express certain queries that has no equivalent JPQL counterpart.
</li>
<li><B>Eager Fetching</B>: The query result displays the Author names as well, though the query
had only selected the Books. But the Authors have also been fetched because
@@ -88,30 +89,29 @@
String query = service.getQuery(title, minPrice, maxPrice, author);
%>
Query : <code><%= query %></code>
-<br>
+<p></p>
<%
if (books.isEmpty()) {
%>
- This query did not select any Book.
- <br>
- <p align="right"><A HREF="<%= PAGE_SEARCH %>">Search again</A></p>
+ did not select any book.
+ <p><A HREF="<%= PAGE_SEARCH %>">Search again</A></p>
<%
return;
}
%>
<br>
<table>
- <caption><%= books.size() %> Books selected</caption>
+ <caption>Selected <%= books.size() %> Book<%= books.size() == 1 ? "" : "s" %></caption>
<thead>
<tr>
- <th>ISBN</th> <th>Title</th> <th>Price</th> <th>Authors</th>
- <th>Add to Cart</th>
+ <th width="08em">ISBN</th>
+ <th width="10em">Title</th>
+ <th width="06em">Price</th>
+ <th width="20em">Authors</th>
+ <th width="16em">Add to Cart</th>
</tr>
</thead>
<tfoot>
- <tr>
- <td><A HREF="<%= PAGE_SEARCH %>">Search again</A></td>
- </tr>
</tfoot>
<tbody>
<%
@@ -126,13 +126,14 @@ Query : <code><%= query %></code>
<TD> <%= namesOf(book.getAuthors()) %> </TD>
<TD> <A HREF="<%= JSPUtility.encodeURL(PAGE_CART,
KEY_ACTION, ACTION_ADD, KEY_ISBN, book.getISBN()) %>">
- Add to Cart</A></TD>
+ <img src="images/add-to-cart.gif" width="106px" height="22px" border="0"></A></TD>
</TR>
<%
}
%>
</tbody>
</table>
+<p>
</div>
<%@include file="footer.jsp"%>
Modified: openjpa/trunk/openjpa-examples/openbooks/web/search.jsp
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/search.jsp?rev=948925&r1=948924&r2=948925&view=diff
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/search.jsp (original)
+++ openjpa/trunk/openjpa-examples/openbooks/web/search.jsp Thu May 27 17:41:43 2010
@@ -21,7 +21,7 @@
<!-- =========================================================== -->
<%@page import="openbook.server.OpenBookService"%>
<%@page import="openbook.domain.Book"%>
-
+<%@page import="javax.servlet.http.HttpServletRequest"%>
<%@include file="header.jsp"%>
<div id="help">
@@ -60,6 +60,15 @@
</div>
<div id="content" style="display: block">
+<%!
+ public static String getParameter(HttpServletRequest request, String param) {
+ return getParameter(request, param, true);
+ }
+ public static String getParameter(HttpServletRequest request, String param, boolean replaceNull) {
+ String value = request.getParameter(param);
+ return replaceNull ? (value == null ? "" : value) : value;
+ }
+%>
<%
OpenBookService service = (OpenBookService)session.getAttribute(KEY_SERVICE);
@@ -74,24 +83,27 @@
Fill in the details for a book you are searching for.
<br>
<form method="GET" action="<%= PAGE_BOOKS %>">
- Title : <br> <input type="text" name="<%= FORM_TITLE %>"><br>
- Author: <br> <input type="text" name="<%= FORM_AUTHOR %>"><br>
- Price : <br> from <input type="text" name="<%= FORM_PRICE_MIN %>"> to
- <input type="text" name="<%= FORM_PRICE_MAX %>"><br>
+ Title : <br> <input type="text" name="<%= FORM_TITLE %>" value="<%= getParameter(request, FORM_TITLE) %>"
+ style="width:20em"><br>
+ Author: <br> <input type="text" name="<%= FORM_AUTHOR %>" value="<%= getParameter(request, FORM_AUTHOR) %>"
+ style="width:20em"><br>
+ Price from : <input type="text" name="<%= FORM_PRICE_MIN %>" value="<%= getParameter(request, FORM_PRICE_MIN) %>"
+ style="width:6em"> to
+ <input type="text" name="<%= FORM_PRICE_MAX %>" value="<%= getParameter(request, FORM_PRICE_MIN) %>"
+ style="width:6em"><br>
<br>
-<input type="submit" value="Search">
+ <input type="image" src="images/search.gif" width="60px" height="22px" border="0">
</form>
-<p>
+<p></p>
<b>Search Tips</b>:
<ol>
<li>You can leave one, more or all fields empty.</li>
<li>OpenBooks database currently contains <%= service.count(Book.class) %> books.</li>
<li>Book titles are <code>Book-1</code>, <code>Book-2</code>, <code>Book-3</code>,...</li>
<li>Author names are <code>Author-1</code>, <code>Author-2</code>, <code>Author-3</code>,...</li>
- <li>Both Book and Author names accept wildcard characters. For example, <code>Book-3_</code>
- will return <code>Book-31</code>, <code>Book-32</code>, <code>Book-33</code> ...
- <li>A Book is written by one or more Author(s).
- <li>An Author may have written zero or more Book(s).
+ <li>Both Book and Author names accept wildcard characters. <br>
+ For example, an underscore like <code>Book-3_</code> will match any single character to return
+ <code>Book-31</code>, <code>Book-32</code>, <code>Book-33</code> ...
</ol>