]> git.mxchange.org Git - pizzaservice-war.git/blobdiff - web/index.jsp
Cleanup
[pizzaservice-war.git] / web / index.jsp
index e6b2b617561b63fa8112475b448e4f05b1212860..ec70c2df286c4f59b72d032ef5fe27b60ee9b76c 100644 (file)
@@ -5,34 +5,35 @@
 --%>
 
 <%--<%@page errorPage="errorHandler.jsp" %>--%>
-<%@page import="java.util.Map"%>
-<%@page import="java.util.Iterator"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
-<%@page import="org.mxchange.pizzaapplication.product.Product"%>
-<%@page import="org.mxchange.pizzaapplication.basket.Basket"%>
-<%@page import="org.mxchange.pizzaapplication.basket.item.ItemBasket"%>
-<%@page import="org.mxchange.pizzaapplication.item.basket.BasketItem"%>
-<%@page import="org.mxchange.pizzaapplication.item.AddableBasketItem"%>
+<%@page import="org.mxchange.pizzaapplication.beans.controller.PizzaBean"%>
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+<%@taglib prefix="basket" uri="http://mxchange.org/jshop/tags/basket" %>
 
+<jsp:useBean id="controller" scope="session" class="org.mxchange.pizzaapplication.beans.controller.PizzaServiceBean" type="PizzaBean" />
+
+<jsp:setProperty name="controller" property="application" value="${pageContext.servletContext}" />
+<jsp:setProperty name="controller" property="basket" value="${basket}" />
 <%
-       // Init application instance
-       PizzaApplication app = PizzaServiceApplication.getInstance(application);
+       // TODO: Can be removed later
+       controller.init();
 %>
+
+<c:set var="basePath" value="${pageContext.request.contextPath}" />
+
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-               <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Willkommen</title>
+               <link rel="stylesheet" href="${basePath}/style.css" type="text/css" />
+               <title>Pizza-Service - Willkommen</title>
        </head>
 
        <body>
                <div id="header"> 
                        <div id="title">
-                               <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Willkommen</h1>
+                               <h1>Pizza-Service - Willkommen</h1>
                        </div>
                </div>
 
 
                <div id="content_outer">
                        <div id="content_title">
-                               <h2>Folgendes kann bestellt werden:</h2>
+                               <h2>Eingangsseite (dummy):</h2>
                        </div>
 
                        <div id="content">
-                               <table class="table">
-                                       <tr>
-                                               <th class="table_header_column">
-                                                       Bestellen?
-                                               </th>
-                                               <th class="table_header_column">
-                                                       Anzahl:
-                                               </th>
-                                               <th class="table_header_column">
-                                                       Produkt:
-                                               </th>
-                                               <th class="table_header_column">
-                                                       Einzelpreis:
-                                               </th>
-                                       </tr>
-                               </table>
-
-                               <%
-                               // Get Iterator
-                               Iterator<Product> iterator = app.getAvailableProducts();
-
-                               // "Walk" through all products and unmark them as ordered
-                               while (iterator.hasNext()) {
-                                       // Get product instance
-                                       Product product = iterator.next();
+                               <!-- TODO: Missing in xhtml: //-->
+                               <basket:mini_basket basket="${basket}" />
 
-                                       // Get basket instance
-                                       Basket<AddableBasketItem> basket = ItemBasket.getInstance(session);
-
-                                       // Create an item instance form this product
-                                       AddableBasketItem item = basket.getItem(product);
-
-                                       // Has it been already added to the basket?
-                                       if (item != null) {
-                                               // Some nice output ...
-                                               %>
                                <table class="table">
-                                       <tbody>
-                                                       <tr>
-                                                               <td class="table_data_column">
-                                                                       <a href="<%=request.getContextPath()%>/basket.jsp" title="Zum Warenkorb">Warenkorb</a>
-                                                               </td>
-                                                               <td class="table_data_column">
-                                                                       <%=item.getAmount()%>
-                                                               </td>
-                                                               <td class="table_data_column">
-                                                                       <%=product.getTitle()%>
-                                                               </td>
-                                                               <td class="table_data_column" align="right">
-                                                                       <fmt:formatNumber type="currency"><%=product.getPrice()%></fmt:formatNumber>
-                                                               </td>
-                                                       </tr>
-                                       </tbody>
-                               </table>
-                                               <%
-                                               // Then skip this item
-                                               continue;
-                                       }
+                                       <thead>
+                                               <tr>
+                                                       <th colspan="4" class="table_header">
+                                                               Folgendes kann bestellt werden:
+                                                       </th>
+                                               </tr>
+                                       </thead>
 
-                                       // Unmark as ordered
-                                       app.unmarkProductAsOrdered(product, session);
-                                       %>
-                               <form action="<%=request.getContextPath()%>/form_handler/add_item.jsp" accept-charset="utf-8" id="form" method="post">
-                               <table class="table">
                                        <tbody>
-                                                       <tr>
-                                                               <td class="table_data_column">
-                                                                       <input class="submit" type="submit" name="add" value="Hinzuf&uuml;gen" />
-                                                                       <input class="input" type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_ID%>" value="<%=product.getId()%>" />
-                                                                       <input class="input" type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_TYPE%>" value="Product" />
-                                                               </td>
-                                                               <td class="table_data_column">
-                                                                       <input class="input" type="text" name="<%=PizzaApplication.HTTP_PARAM_AMOUNT%>" size="3" maxlength="20" />
-                                                               </td>
-                                                               <td class="table_data_column">
-                                                                       <%=product.getTitle()%>
-                                                               </td>
-                                                               <td class="table_data_column" align="right">
-                                                                       <fmt:formatNumber type="currency"><%=product.getPrice()%></fmt:formatNumber>
-                                                               </td>
-                                                       </tr>
+                                               <tr>
+                                                       <th class="table_header_column">
+                                                               Bestellen?
+                                                       </th>
+                                                       <th class="table_header_column">
+                                                               Anzahl:
+                                                       </th>
+                                                       <th class="table_header_column">
+                                                               Produkt:
+                                                       </th>
+                                                       <th class="table_header_column">
+                                                               Einzelpreis:
+                                                       </th>
+                                               </tr>
                                        </tbody>
                                </table>
-                               </form>
-                               <%
-                       }
-                       %>
+
+                               <c:forEach var="product" items="${controller.availableProductsIterator}">
+                                       <c:choose>
+                                               <c:when test="${controller.basket.isAdded(product)}">
+                                                       <c:set var="item" value="${controller.basket.item}" />
+                                                       <table class="table">
+                                                               <tbody>
+                                                                               <tr>
+                                                                                       <td class="table_data_column">
+                                                                                               <a href="${basePath}/basket.jsp" title="Zum Warenkorb">Warenkorb</a>
+                                                                                       </td>
+                                                                                       <td class="table_data_column">
+                                                                                               ${item.amount}
+                                                                                       </td>
+                                                                                       <td class="table_data_column">
+                                                                                               ${product.title}
+                                                                                       </td>
+                                                                                       <td class="table_data_column" align="right">
+                                                                                               <fmt:formatNumber type="currency" minFractionDigits="2" maxFractionDigits="2" value="${product.price}" />
+                                                                                       </td>
+                                                                               </tr>
+                                                               </tbody>
+                                                       </table>
+                                               </c:when>
+                                               <c:otherwise>
+                                                       <form action="${basePath}/form_handler/add_item.jsp" accept-charset="utf-8" id="form" method="post">
+                                                       <table class="table">
+                                                               <tbody>
+                                                                               <tr>
+                                                                                       <td class="table_data_column">
+                                                                                               <input class="submit" type="submit" name="add" value="Hinzuf&uuml;gen" />
+                                                                                               <input type="hidden" name="itemId" value="${product.itemId}" />
+                                                                                               <input type="hidden" name="itemType" value="Product" />
+                                                                                       </td>
+                                                                                       <td class="table_data_column">
+                                                                                               <input class="input" type="text" name="amount" size="3" maxlength="20" />
+                                                                                       </td>
+                                                                                       <td class="table_data_column">
+                                                                                               ${product.title}
+                                                                                       </td>
+                                                                                       <td class="table_data_column" align="right">
+                                                                                               <fmt:formatNumber type="currency" minFractionDigits="2" maxFractionDigits="2" value="${product.price}" />
+                                                                                       </td>
+                                                                               </tr>
+                                                               </tbody>
+                                                       </table>
+                                                       </form>
+                                               </c:otherwise>
+                                       </c:choose>
+                               </c:forEach>
                        </div>
                </div>