Author : Roland Haeder
--%>
-<%@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 errorPage="errorHandler.jsp" %>--%>
+<%@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%> - Eingangsseite</title>
+ <link rel="stylesheet" href="${basePath}/style.css" type="text/css" />
+ <title>Pizza-Service - Willkommen</title>
</head>
<body>
- <div id="title">
- <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Eingangsseite</h1>
+ <div id="header">
+ <div id="title">
+ <h1>Pizza-Service - Willkommen</h1>
+ </div>
</div>
- <jsp:include page="/static/menu.jsp" flush="true" />
+ <jsp:include page="/static/guest/guest_menu.jsp" flush="false" />
<div id="content_outer">
<div id="content_title">
- <h2>Folgendes kann bestellt werden:</h2>
+ <h2>Eingangsseite (dummy):</h2>
</div>
<div id="content">
- <form action="<%=request.getContextPath()%>/form_handler/do_preview.jsp" accept-charset="utf-8" id="form" method="post">
+ <basket:mini_basket basket="${basket}" />
+
<table class="table">
- <thead class="table_header">
+ <thead>
+ <tr>
+ <th colspan="4" class="table_header">
+ Folgendes kann bestellt werden:
+ </th>
+ </tr>
+ </thead>
+
+ <tbody>
<tr>
<th class="table_header_column">
Bestellen?
Einzelpreis:
</th>
</tr>
- </thead>
-
- <tbody class="table_body">
- <%
- // "Walk" through all products and unmark them as ordered
- for (final Product product : app.getUnmarkedProducts(session)) {
- %>
- <tr>
- <td>
- <input type="checkbox" name="<%=String.format(PizzaApplication.HTTP_PARAM_MASK, PizzaApplication.HTTP_PARAM_CHOOSE, product.getName())%>" value="1" <%=app.getCheckedHtmlFromProduct(product, request, session)%> />
- </td>
- <td>
- <input type="text" name="<%=String.format(PizzaApplication.HTTP_PARAM_MASK, PizzaApplication.HTTP_PARAM_AMOUNT, product.getName())%>" value="<%=app.getAmountFromSession(product, session)%>" size="3" maxlength="20" />
- </td>
- <td>
- <%=product.getTitle()%>
- </td>
- <td>
- <%=product.getPrice()%>
- </td>
- </tr>
- <%
- }
- %>
-
- <tr>
- <td colspan="4" class="table_footer">
- <input type="reset" value="Formular zurücksetzen" />
- <input type="submit" name="send" value="Bestellung ansehen" />
- </td>
- </tr>
</tbody>
</table>
- </form>
+
+ <c:forEach var="product" items="${controller.availableProducts}">
+ <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ü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>
+
+ <jsp:include page="/static/guest/guest_footer.jsp" flush="false" />
</body>
</html>