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/21 00:11:39 UTC
svn commit: r946810 - in /openjpa/trunk/openjpa-examples/openbooks/web: ./
cart.jsp checkout.jsp footer.jsp header.jsp intro.jsp openbooks.css
openbooks.js orders.jsp query.jsp register.jsp search.jsp
Author: ppoddar
Date: Thu May 20 22:11:38 2010
New Revision: 946810
URL: http://svn.apache.org/viewvc?rev=946810&view=rev
Log:
Add JSP based web client
Added:
openjpa/trunk/openjpa-examples/openbooks/web/
openjpa/trunk/openjpa-examples/openbooks/web/cart.jsp (with props)
openjpa/trunk/openjpa-examples/openbooks/web/checkout.jsp (with props)
openjpa/trunk/openjpa-examples/openbooks/web/footer.jsp (with props)
openjpa/trunk/openjpa-examples/openbooks/web/header.jsp (with props)
openjpa/trunk/openjpa-examples/openbooks/web/intro.jsp (with props)
openjpa/trunk/openjpa-examples/openbooks/web/openbooks.css (with props)
openjpa/trunk/openjpa-examples/openbooks/web/openbooks.js (with props)
openjpa/trunk/openjpa-examples/openbooks/web/orders.jsp (with props)
openjpa/trunk/openjpa-examples/openbooks/web/query.jsp (with props)
openjpa/trunk/openjpa-examples/openbooks/web/register.jsp (with props)
openjpa/trunk/openjpa-examples/openbooks/web/search.jsp (with props)
Added: openjpa/trunk/openjpa-examples/openbooks/web/cart.jsp
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/cart.jsp?rev=946810&view=auto
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/cart.jsp (added)
+++ openjpa/trunk/openjpa-examples/openbooks/web/cart.jsp Thu May 20 22:11:38 2010
@@ -0,0 +1,84 @@
+<%--
+ * 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.
+--%>
+<!-- =============================================================================================== -->
+<!-- This JSP page demonstrates usage of OpenBookService to browse, select and purchase Books. -->
+<!-- =============================================================================================== -->
+<%@page import="openbook.server.OpenBookService"%>
+<%@page import="openbook.domain.Book"%>
+<%@page import="openbook.domain.Customer"%>
+<%@page import="openbook.domain.ShoppingCart"%>
+<%@page import="java.util.Map"%>
+<%@page import="openbook.util.JSPUtility"%>
+
+<%@include file="header.jsp"%>
+
+<div id="content" style="display: block">
+
+<%
+ OpenBookService service = (OpenBookService)session.getAttribute(KEY_SERVICE);
+ Customer customer = (Customer)session.getAttribute(KEY_USER);
+ ShoppingCart cart = (ShoppingCart)session.getAttribute(KEY_CART);
+ if (ACTION_ADD.equals(request.getParameter(KEY_ACTION))) {
+ String isbn = request.getParameter(KEY_ISBN);
+ Book book = (Book)session.getAttribute(isbn);
+ cart.addItem(book, 1);
+ }
+ if (cart.isEmpty()) {
+%>
+ <h3><%= customer.getName() %>, your Shopping Cart is empty.</h3><br>
+ <A HREF="<%= PAGE_SEARCH %>">Continue Shopping</A>
+<%
+ } else {
+%>
+
+
+<table border="0">
+ <caption><%= customer.getName() %>, your Shopping Cart has <%= cart.getTotalCount() %> books</caption>
+ <thead>
+ <tr>
+ <th>Title</th> <th>Price</th> <th>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>
+ </tr>
+ </tfoot>
+ <tbody>
+<%
+ }
+ Map<Book,Integer> books = cart.getItems();
+ int i = 0;
+ for (Book b : books.keySet()) {
+%>
+ <TR style="<%= JSPUtility.getRowStyle(i++) %>">
+ <TD> <%= b.getTitle() %> </TD>
+ <TD> <%= JSPUtility.format(b.getPrice()) %> </TD>
+ <TD> <%= books.get(b) %> </TD>
+ </TR>
+<%
+ }
+%>
+ </tbody>
+</table>
+
+
+</div>
+<%@include file="footer.jsp"%>
Propchange: openjpa/trunk/openjpa-examples/openbooks/web/cart.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-examples/openbooks/web/checkout.jsp
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/checkout.jsp?rev=946810&view=auto
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/checkout.jsp (added)
+++ openjpa/trunk/openjpa-examples/openbooks/web/checkout.jsp Thu May 20 22:11:38 2010
@@ -0,0 +1,80 @@
+<%--
+ * 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.
+--%>
+<!-- =============================================================================================== -->
+<!-- This JSP page demonstrates usage of OpenBookService to purchase Books. -->
+<!-- =============================================================================================== -->
+<%@page import="openbook.server.OpenBookService"%>
+<%@page import="openbook.domain.Book"%>
+<%@page import="openbook.domain.ShoppingCart"%>
+<%@page import="openbook.domain.PurchaseOrder"%>
+<%@page import="openbook.domain.LineItem"%>
+<%@page import="java.util.Map"%>
+<%@page import="java.util.List"%>
+<%@page import="openbook.util.JSPUtility"%>
+
+<%@include file="header.jsp"%>
+
+
+
+<div id="content" style="display: block">
+<h2>Thank you for buying books from OpenBooks!</h2>
+<%
+ OpenBookService service = (OpenBookService)session.getAttribute(KEY_SERVICE);
+ ShoppingCart cart = (ShoppingCart)session.getAttribute(KEY_CART);
+ PurchaseOrder order = service.placeOrder(cart);
+
+%>
+Order : <%= order.getId() %> <br>
+Placed on <%= JSPUtility.format(order.getPlacedOn()) %>
+
+<table border="0">
+ <caption><%= order.getItems().size() %> items</caption>
+ <thead>
+ <tr>
+ <th>Title</th> <th>Price</th> <th>Quantity</th>
+ </tr>
+ </thead>
+ <tfoot>
+ <tr>
+ <td><A HREF="<%= PAGE_SEARCH %>">Continue Shopping</A></td>
+ </tr>
+ </tfoot>
+ <tbody>
+<%
+ int i = 0;
+ List<LineItem> items = order.getItems();
+ for (LineItem item : items) {
+%>
+ <TR style="<%= JSPUtility.getRowStyle(i++) %>">
+ <TD> <%= item.getBook().getTitle() %> </TD>
+ <TD> <%= item.getQuantity() %> </TD>
+ <TD> <%= JSPUtility.format(item.getBook().getPrice() * item.getQuantity()) %> </TD>
+ </TR>
+<%
+ }
+%>
+ <TR>
+ <TD>Total</TD><TD><%= JSPUtility.format(order.getTotal()) %></TD>
+ </TR>
+ </tbody>
+</table>
+
+
+</div>
+<%@include file="footer.jsp"%>
Propchange: openjpa/trunk/openjpa-examples/openbooks/web/checkout.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-examples/openbooks/web/footer.jsp
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/footer.jsp?rev=946810&view=auto
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/footer.jsp (added)
+++ openjpa/trunk/openjpa-examples/openbooks/web/footer.jsp Thu May 20 22:11:38 2010
@@ -0,0 +1,29 @@
+<%--
+ * 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.
+--%>
+<!-- ========================================================================= -->
+<!-- This footer file is included in every page of OpenBooks web application -->
+<!-- The footer closes the tags opened in header.jsp -->
+<!-- ========================================================================= -->
+<%@page import="org.apache.openjpa.conf.OpenJPAVersion"%>
+<div id="footer">
+ <img src="images/openjpa-logo-small.png" height="20px">
+ Running on <%= OpenJPAVersion.VERSION_ID %>
+</div>
+</BODY>
+</HTML>
Propchange: openjpa/trunk/openjpa-examples/openbooks/web/footer.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-examples/openbooks/web/header.jsp
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/header.jsp?rev=946810&view=auto
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/header.jsp (added)
+++ openjpa/trunk/openjpa-examples/openbooks/web/header.jsp Thu May 20 22:11:38 2010
@@ -0,0 +1,116 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<%--
+ * 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.
+--%>
+<!-- ========================================================================= -->
+<!-- This layout page is included in every page of OpenBooks web application -->
+<!-- The layout splits the screen into four divisions -->
+<!-- header : a header section -->
+<!-- left : houses the navigation menu items -->
+<!-- content: houses JSP page content -->
+<!-- footer : a footer section -->
+<!-- This page has not properly closed its HTML or BODY tag. The tags are -->
+<!-- closed by the footer page -->
+<!-- ========================================================================= -->
+
+<HTML>
+
+<HEAD>
+<title>OpenBooks: A sample JPA web application</title>
+<link type="text/css" rel="stylesheet" href="openbooks.css">
+<script type="text/javascript" src="openbooks.js"></script>
+</HEAD>
+
+<body>
+<%!
+ /**
+ * Lookup keys for Session/Requeust data used throught pages.
+ */
+ public static String KEY_USER = "user";
+ public static String KEY_SERVICE = "OpenBookService";
+ public static String KEY_CART = "cart";
+ public static String KEY_ACTION = "action";
+ public static String KEY_ISBN = "isbn";
+ public static String KEY_OID = "oid";
+
+ public static String ACTION_ADD = "add";
+ public static String ACTION_DELIVER = "deliver";
+ public static String ACTION_DETAILS = "details";
+
+ public static String PAGE_BOOKS = "query.jsp";
+ public static String PAGE_ORDERS = "orders.jsp";
+ public static String PAGE_CART = "cart.jsp";
+ public static String PAGE_HOME = "intro.jsp";
+ public static String PAGE_LOGIN = "register.jsp";
+ public static String PAGE_SEARCH = "search.jsp";
+ public static String PAGE_CHECKOUT = "checkout.jsp";
+
+ public static String FORM_TITLE = "title";
+ public static String FORM_AUTHOR = "title";
+ public static String FORM_PRICE_MAX = "maxPrice";
+ public static String FORM_PRICE_MIN = "minPrice";
+%>
+
+<!-- Header division displays the title and right-justified current user name -->
+<!-- and a Shopping Cart icon for active sessions -->
+<div id="header">
+<table>
+ <colgroup>
+ <col align="left" width="75%">
+ <col align="right" width="25%">
+ </colgroup>
+ <TBODY>
+ <TR>
+ <TD><img src="images/OpenBooks.jpg" width="25px" height="25px" border="0"> OpenBooks</TD>
+ <TD>
+<%
+ Object currentUser = session.getAttribute("user");
+ boolean activeSession = currentUser != null;
+ if (activeSession) {
+%>
+ <A HREF="cart.jsp"><img src="images/Add2Cart.jpg" border="0" width="25px" height="25px"></A>
+ <%= currentUser.toString() %>
+<%
+ }
+%>
+ </TD>
+ </TR>
+ </TBODY>
+</table>
+</div>
+
+<!-- Left menu navigation displays the items based on current session status -->
+<!-- and a Shopping Cart icon for active sessions -->
+
+<div id="left">
+
+<ul>
+ <li><a href="intro.jsp">Login</a></li>
+<%
+ if (activeSession) {
+%>
+ <li><a href="search.jsp">Search/Buy Books</a></li>
+ <li><a href="orders.jsp">View Orders</a></li>
+<%
+ }
+%>
+ <li><a href="http://fisheye6.atlassian.com/browse/openjpa/trunk/openjpa-examples/openbooks/src/main/java/openbook/server/OpenBookService.java?r=HEAD"
+ target="_blank">
+ View Code</a></li>
+</ul>
+</div>
Propchange: openjpa/trunk/openjpa-examples/openbooks/web/header.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-examples/openbooks/web/intro.jsp
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/intro.jsp?rev=946810&view=auto
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/intro.jsp (added)
+++ openjpa/trunk/openjpa-examples/openbooks/web/intro.jsp Thu May 20 22:11:38 2010
@@ -0,0 +1,40 @@
+<%--
+ * 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.
+--%>
+
+<%@include file="header.jsp"%>
+
+<div id="content" style="display: block">
+<b>OpenBooks</b> is a sample web application demonstrating some new features in JPA 2.0 API.
+<br>
+Please enter your name below to start a OpenBooks session.
+<br>
+<%
+ Object service = session.getAttribute(KEY_SERVICE);
+ if (service == null) {
+%>
+ <form method="get" action="<%= PAGE_LOGIN %>">
+ Your Name :<br> <input type="text" name="<%= KEY_USER %>" size="40"> <br>
+ <input type="SUBMIT" value="Enter">
+ </form>
+<%
+ }
+%>
+</div>
+
+<%@include file="footer.jsp"%>
Propchange: openjpa/trunk/openjpa-examples/openbooks/web/intro.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-examples/openbooks/web/openbooks.css
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/openbooks.css?rev=946810&view=auto
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/openbooks.css (added)
+++ openjpa/trunk/openjpa-examples/openbooks/web/openbooks.css Thu May 20 22:11:38 2010
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+/* ----------------------------------------------------------------------------
+ Cascaded Style Sheet for OpenBooks pages.
+
+ The page is divided into 4 divisions.
+ A fixed header and footer.
+ A left menu.
+ A central content section.
+
+ All divisions are referred by id in HTML <div> tag.
+ -------------------------------------------------------------------------- */
+
+#header {
+ width: 100%;
+ height: 30px;
+ margin: 5px;
+ padding: 10px;
+
+ background: #fff;
+ z-index: 100;
+
+ font-size:120%;
+
+ border-bottom: 1px solid #999;
+}
+
+#left {
+ position: absolute;
+
+ width: 120px;
+ top: 60px;
+ margin-left:10px;
+
+ font:16pt;
+}
+
+#content {
+ top: 0;
+ margin-left: 160px;
+ margin-right: 300px;
+ margin-top:30px;
+ padding: 10px 10px;
+}
+
+#footer {
+ position: fixed;
+
+ width: 100%;
+ height: 20px;
+
+ padding-top: 2px;
+ padding-bottom: 2px;
+ bottom: 0;
+ z-index: 10;
+ background: #fff;
+ text-align: left;
+ border-top: 1px solid #000;
+ font-size:120%;
+}
\ No newline at end of file
Propchange: openjpa/trunk/openjpa-examples/openbooks/web/openbooks.css
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-examples/openbooks/web/openbooks.js
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/openbooks.js?rev=946810&view=auto
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/openbooks.js (added)
+++ openjpa/trunk/openjpa-examples/openbooks/web/openbooks.js Thu May 20 22:11:38 2010
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+/**
+ * Shows a page in the right division.
+ */
+function showPage(id, body) {
+ var el = document.getElementById(id);
+ el.innerHTML = body;
+}
+
Propchange: openjpa/trunk/openjpa-examples/openbooks/web/openbooks.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-examples/openbooks/web/orders.jsp
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/orders.jsp?rev=946810&view=auto
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/orders.jsp (added)
+++ openjpa/trunk/openjpa-examples/openbooks/web/orders.jsp Thu May 20 22:11:38 2010
@@ -0,0 +1,156 @@
+<%--
+ * 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.
+--%>
+<!-- =============================================================================================== -->
+<!-- This JSP page demonstrates usage of OpenBookService to browse, select and purchase Books. -->
+<!-- =============================================================================================== -->
+<%@page import="openbook.server.OpenBookService"%>
+<%@page import="openbook.domain.Book"%>
+<%@page import="openbook.domain.Customer"%>
+<%@page import="openbook.domain.ShoppingCart"%>
+<%@page import="openbook.domain.PurchaseOrder"%>
+<%@page import="openbook.domain.LineItem"%>
+<%@page import="openbook.util.JSPUtility"%>
+<%@page import="java.util.Map"%>
+<%@page import="java.util.List"%>
+
+<%@include file="header.jsp"%>
+
+<div id="content" style="display: block">
+
+<%
+ OpenBookService service = (OpenBookService)session.getAttribute(KEY_SERVICE);
+ if (service == null) {
+%>
+ <jsp:forward page="<%= PAGE_HOME %>"></jsp:forward>
+<%
+ }
+ if (ACTION_DELIVER.equals(request.getParameter(KEY_ACTION))) {
+ String oid = request.getParameter(KEY_OID);
+ PurchaseOrder order = (PurchaseOrder)session.getAttribute(oid);
+ service.deliver(order);
+ }
+
+ Customer customer = (Customer)session.getAttribute(KEY_USER);
+ List<PurchaseOrder> orders = service.getOrders(null, customer);
+%>
+All <%= orders.size() %> Purchase Order placed by <%= customer.getName() %> is shown.
+The <code>Deliver</code> button will deliver the pending order. Delivery of a pending
+order <br>
+<OL>
+<LI>decrements inventory of all associated LineItems</LI>
+<LI>changes status to ORDERED and finally </LI>
+<LI>nullifies the association between Purchase Order and Line Items. Nullifying the
+association has the important side-effect of deleting the line items from the database
+because Purchase Order and Line Items relation is annotated as orphan delete.</LI>
+</OL>
+<br>
+
+<table border="0">
+ <caption><%= customer.getName() %> placed <%= orders.size() %> orders</caption>
+ <thead>
+ <tr>
+ <th>ID</th> <th>Total</th> <th>Placed On</th> <th>Status</th> <th>Delivered On</th>
+ </tr>
+ </thead>
+ <tfoot>
+ <tr>
+ <td><A HREF="<%= PAGE_SEARCH %>">Continue Shopping</A></td>
+ </tr>
+ </tfoot>
+ <tbody>
+<%
+ int i = 0;
+ for (PurchaseOrder order : orders) {
+ session.setAttribute(""+order.getId(), order);
+%>
+ <TR style="<%= JSPUtility.getRowStyle(i++) %>">
+ <TD> <A HREF="<%=
+ JSPUtility.encodeURL(PAGE_ORDERS,
+ KEY_ACTION, ACTION_DETAILS,
+ KEY_OID, order.getId()) %>"> <%= order.getId() %></A></TD>
+ <TD> <%= order.getTotal() %> </TD>
+ <TD> <%= JSPUtility.format(order.getPlacedOn()) %> </TD>
+ <TD> <%= order.getStatus() %> </TD>
+<%
+ if (order.getStatus().equals(PurchaseOrder.Status.PENDING)) {
+%>
+ <TD> </TD>
+ <TD> <A HREF="<%=
+ JSPUtility.encodeURL(PAGE_ORDERS, KEY_ACTION, ACTION_DELIVER,
+ KEY_OID, order.getId()) %>">Deliver</A></TD>
+<%
+ } else {
+%>
+ <TD> <%= JSPUtility.format(order.getDeliveredOn()) %> </TD>
+ <TD> </TD>
+<%
+ }
+%>
+ </TR>
+<%
+ }
+%>
+ </tbody>
+</table>
+
+
+<%
+ 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 && order.getStatus().equals(PurchaseOrder.Status.PENDING)) {
+%>
+<table border="0">
+ <caption><%= items.size() %> line items of Order <%= order.getId() %></caption>
+ <thead>
+ <tr>
+ <th>Title</th> <th>Price</th> <th>Quantity</th> <th>Cost</th>
+ </tr>
+ </thead>
+ <tbody>
+<%
+ int j = 0;
+ for (LineItem item : items) {
+%>
+ <TR style="<%= JSPUtility.getRowStyle(j++) %>">
+ <TD> <%= item.getBook().getTitle() %> </TD>
+ <TD> <%= JSPUtility.format(item.getBook().getPrice()) %> </TD>
+ <TD> <%= item.getQuantity() %> </TD>
+ <TD> <%= JSPUtility.format(item.getBook().getPrice() * item.getQuantity()) %> </TD>
+ </TR>
+<%
+ }
+%>
+ <TR>
+ <TD>Total</TD><TD><%= JSPUtility.format(order.getTotal()) %></TD>
+ </TR>
+ </tbody>
+</table>
+<%
+ }
+ }
+%>
+
+
+
+</div>
+
+
+<%@include file="footer.jsp"%>
Propchange: openjpa/trunk/openjpa-examples/openbooks/web/orders.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-examples/openbooks/web/query.jsp
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/query.jsp?rev=946810&view=auto
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/query.jsp (added)
+++ openjpa/trunk/openjpa-examples/openbooks/web/query.jsp Thu May 20 22:11:38 2010
@@ -0,0 +1,107 @@
+<%--
+ * 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.
+--%>
+<%-- ==================================================================== --%>
+<%-- Executes a query which is determined by the request parameter. --%>
+<%-- Displays the results --%>
+<%-- ==================================================================== --%>
+<%@include file="header.jsp"%>
+
+
+<%@page import="openbook.server.OpenBookService"%>
+<%@page import="openbook.domain.Book"%>
+<%@page import="openbook.domain.Author"%>
+<%@page import="openbook.util.JSPUtility"%>
+<%@page import="java.util.List"%>
+
+<div id="content" style="display: block">
+<%!
+ /**
+ * Concatenates the names of the given list of Authors.
+ *
+ */
+ public static String namesOf(List<Author> authors) {
+ StringBuilder names = new StringBuilder();
+ if (authors == null)
+ return names.toString();
+ for (Author a : authors) {
+ if (names.length() != 0) names.append(", ");
+ names.append(a.getName());
+ }
+ return names.toString();
+ }
+%>
+
+
+<%
+ OpenBookService service = (OpenBookService)session.getAttribute(KEY_SERVICE);
+ if (service == null) {
+%>
+ <jsp:forward page="<%= PAGE_HOME %>"></jsp:forward>
+<%
+ }
+%>
+
+<%
+ String title = request.getParameter(FORM_TITLE);
+ Double minPrice = JSPUtility.toDouble(request.getParameter(FORM_PRICE_MIN));
+ Double maxPrice = JSPUtility.toDouble(request.getParameter(FORM_PRICE_MAX));
+ String author = request.getParameter(FORM_AUTHOR);
+
+ List<Book> books = service.select(title, minPrice, maxPrice, author);
+ String query = service.getQuery(title, minPrice, maxPrice, author);
+%>
+The query executed on the server was <br>
+<pre><%= query %></pre>
+<br>
+This query selected <%= books.size() %> books.<br>
+<table border="0">
+ <thead>
+ <tr>
+ <th>ISBN</th> <th>Title</th> <th>Price</th> <th>Authors</th>
+ <th><img src="images/Add2Cart.jpg" border="0" width="20px" height="20px"></th>
+ </tr>
+ </thead>
+ <tfoot>
+ <tr>
+ <td><A HREF="<%= PAGE_SEARCH %>">Search again</A></td>
+ </tr>
+ </tfoot>
+ <tbody>
+<%
+ int i = 0;
+ for (Book book : books) {
+ session.setAttribute(book.getISBN(), book);
+%>
+ <TR style="<%= JSPUtility.getRowStyle(i++) %>">
+ <TD> <%= book.getISBN() %> </TD>
+ <TD> <%= book.getTitle() %> </TD>
+ <TD> <%= JSPUtility.format(book.getPrice()) %> </TD>
+ <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>
+ </TR>
+<%
+ }
+%>
+ </tbody>
+</table>
+
+</div>
+<%@include file="footer.jsp"%>
Propchange: openjpa/trunk/openjpa-examples/openbooks/web/query.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-examples/openbooks/web/register.jsp
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/register.jsp?rev=946810&view=auto
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/register.jsp (added)
+++ openjpa/trunk/openjpa-examples/openbooks/web/register.jsp Thu May 20 22:11:38 2010
@@ -0,0 +1,48 @@
+<%--
+ * 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.
+--%>
+<%@include file="header.jsp"%>
+
+<%@page import="openbook.server.ServiceFactory"%>
+<%@page import="openbook.server.OpenBookService"%>
+<%@page import="openbook.domain.Customer"%>
+<%@page import="java.util.List"%>
+
+<div id="content" style="display: block">
+
+<%-- ==================================================================== --%>
+<%-- Associates the current session with OpenBookService, if the request --%>
+<%-- carries user parameter. Otherwise redirects to login page. --%>
+<%-- ==================================================================== --%>
+<%
+ Object user = request.getParameter(KEY_USER);
+ String nextPage = PAGE_HOME;
+ if (user != null && user.toString().trim().length() > 0) {
+ OpenBookService service = ServiceFactory.getService("OpenBooks");
+ service.initialize(null);
+ Customer customer = service.login(user.toString());
+ session.setAttribute(KEY_USER, customer);
+ session.setAttribute(KEY_CART, customer.newCart());
+ session.setAttribute(KEY_SERVICE, service);
+ nextPage = PAGE_SEARCH;
+ }
+%>
+ <jsp:forward page="<%=nextPage%>"/>
+
+</div>
+<%@include file="footer.jsp"%>
Propchange: openjpa/trunk/openjpa-examples/openbooks/web/register.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-examples/openbooks/web/search.jsp
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-examples/openbooks/web/search.jsp?rev=946810&view=auto
==============================================================================
--- openjpa/trunk/openjpa-examples/openbooks/web/search.jsp (added)
+++ openjpa/trunk/openjpa-examples/openbooks/web/search.jsp Thu May 20 22:11:38 2010
@@ -0,0 +1,52 @@
+<%--
+ * 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.
+--%>
+<!-- =============================================================================================== -->
+<!-- This JSP page demonstrates usage of OpenBookService to browse, select and purchase Books. -->
+<!-- =============================================================================================== -->
+<%@page import="openbook.server.OpenBookService"%>
+<%@page import="openbook.domain.Book"%>
+
+<%@include file="header.jsp"%>
+
+<div id="content" style="display: block">
+
+<%
+ OpenBookService service = (OpenBookService)session.getAttribute(KEY_SERVICE);
+ if (service == null) {
+%>
+ <jsp:forward page="<%= PAGE_HOME %>"></jsp:forward>
+<%
+ }
+%>
+OpenBooks database contains <%= service.count(Book.class) %> books.
+<br>
+Fill in the details for a book you are searching for.
+<br>
+You can leave one, more or all fields empty.
+<hr>
+<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>
+ <hr>
+<input type="submit" value="Search">
+</form>
+</div>
+<%@include file="footer.jsp"%>
Propchange: openjpa/trunk/openjpa-examples/openbooks/web/search.jsp
------------------------------------------------------------------------------
svn:eol-style = native