]> git.mxchange.org Git - pizzaservice-war.git/blob - web/index.jsp
Updated jshop.jar + comment in index.jsp
[pizzaservice-war.git] / web / index.jsp
1 <%-- 
2         Document   : index
3         Created on : 04.08.2015, 10:33:10
4         Author     : Roland Haeder
5 --%>
6
7 <%--<%@page errorPage="errorHandler.jsp" %>--%>
8 <%@page import="java.util.Map"%>
9 <%@page import="java.util.Iterator"%>
10 <%@page import="org.mxchange.jshop.product.Product"%>
11 <%@page import="org.mxchange.jshop.basket.Basket"%>
12 <%@page import="org.mxchange.jshop.item.basket.BasketItem"%>
13 <%@page import="org.mxchange.jshop.item.AddableBasketItem"%>
14 <%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
15 <%@page import="org.mxchange.pizzaapplication.beans.controller.PizzaBean"%>
16 <%@page contentType="text/html" pageEncoding="UTF-8"%>
17 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
18 <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
19 <%@taglib prefix="basket" uri="http://mxchange.org/jshop/tags/basket" %>
20
21 <jsp:useBean id="controller" scope="session" class="org.mxchange.pizzaapplication.beans.controller.PizzaServiceBean" type="PizzaBean" />
22
23 <jsp:setProperty name="controller" property="application" value="${pageContext.servletContext}" />
24 <jsp:setProperty name="controller" property="basket" value="${basket}" />
25 <%controller.init();%>
26
27 <c:set var="basePath" value="${pageContext.request.contextPath}" />
28
29 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
30 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
31         <head>
32                 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
33                 <link rel="stylesheet" href="${basePath}/style.css" type="text/css"/>
34                 <title>Pizza-Service - Willkommen</title>
35         </head>
36
37         <body>
38                 <div id="header"> 
39                         <div id="title">
40                                 <h1>Pizza-Service - Willkommen</h1>
41                         </div>
42                 </div>
43
44                 <jsp:include page="/static/guest/guest_menu.jsp" flush="false" />
45
46                 <div id="content_outer">
47                         <div id="content_title">
48                                 <h2>Folgendes kann bestellt werden:</h2>
49                         </div>
50
51                         <div id="content">
52                                 <basket:mini_basket basket="${basket}" />
53
54                                 <table class="table">
55                                         <tr>
56                                                 <th class="table_header_column">
57                                                         Bestellen?
58                                                 </th>
59                                                 <th class="table_header_column">
60                                                         Anzahl:
61                                                 </th>
62                                                 <th class="table_header_column">
63                                                         Produkt:
64                                                 </th>
65                                                 <th class="table_header_column">
66                                                         Einzelpreis:
67                                                 </th>
68                                         </tr>
69                                 </table>
70
71                                 <%
72                                 // Get Iterator
73                                 Iterator<Product> iterator = controller.getAvailableProducts();
74
75                                 // "Walk" through all products and unmark them as ordered
76                                 while (iterator.hasNext()) {
77                                         // Get product instance
78                                         Product product = iterator.next();
79
80                                         // Debug message
81                                         controller.getLogger().debug("product=" + product);
82
83                                         // Create an item instance form this product
84                                         AddableBasketItem item = controller.getBasket().getItem(product);
85
86                                         // Debug message
87                                         controller.getLogger().debug("item=" + item);
88
89                                         // Has it been already added to the basket?
90                                         if (item != null) {
91                                                 // Item was added to basket
92                                                 %>
93                                                 <table class="table">
94                                                         <tbody>
95                                                                         <tr>
96                                                                                 <td class="table_data_column">
97                                                                                         <a href="${basePath}/basket.jsp" title="Zum Warenkorb">Warenkorb</a>
98                                                                                 </td>
99                                                                                 <td class="table_data_column">
100                                                                                         <%=item.getAmount()%>
101                                                                                 </td>
102                                                                                 <td class="table_data_column">
103                                                                                         <%=product.getTitle()%>
104                                                                                 </td>
105                                                                                 <td class="table_data_column" align="right">
106                                                                                         <fmt:formatNumber type="currency" minFractionDigits="2" maxFractionDigits="2" value="<%=product.getPrice()%>" />
107                                                                                 </td>
108                                                                         </tr>
109                                                         </tbody>
110                                                 </table>
111                                                 <%
112                                         } else {
113                                                 %>
114                                                 <form action="${basePath}/form_handler/add_item.jsp" accept-charset="utf-8" id="form" method="post">
115                                                 <table class="table">
116                                                         <tbody>
117                                                                         <tr>
118                                                                                 <td class="table_data_column">
119                                                                                         <input class="submit" type="submit" name="add" value="Hinzuf&uuml;gen" />
120                                                                                         <input type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_ID%>" value="<%=product.getItemId()%>" />
121                                                                                         <input type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_TYPE%>" value="Product" />
122                                                                                 </td>
123                                                                                 <td class="table_data_column">
124                                                                                         <input class="input" type="text" name="<%=PizzaApplication.HTTP_PARAM_AMOUNT%>" size="3" maxlength="20" />
125                                                                                 </td>
126                                                                                 <td class="table_data_column">
127                                                                                         <%=product.getTitle()%>
128                                                                                 </td>
129                                                                                 <td class="table_data_column" align="right">
130                                                                                         <fmt:formatNumber type="currency" minFractionDigits="2" maxFractionDigits="2" value="<%=product.getPrice()%>" />
131                                                                                 </td>
132                                                                         </tr>
133                                                         </tbody>
134                                                 </table>
135                                                 </form>
136                                 <%
137                                         }
138                                 }
139                         %>
140                         </div>
141                 </div>
142
143                 <jsp:include page="/static/guest/guest_footer.jsp" flush="false" />
144         </body>
145 </html>