-<?xml version='1.0' encoding='UTF-8' ?>
-<!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" xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:f="http://xmlns.jcp.org/jsf/core">
- <ui:param name="path" value="#{request.contextPath}" />
- <h:head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <link rel="stylesheet" href="#{path}/style.css" type="text/css"/>
- <title>Willkommen</title>
- </h:head>
- <h:body>
- <div id="header">
- <div id="title">
- <h1>Willkommen</h1>
- </div>
- </div>
-
- <ui:include src="/static/guest/guest_menu.xhtml" id="menu" />
-
- <div id="content_outer">
- <div id="content_title">
- <h2>Folgendes kann bestellt werden:</h2>
- </div>
-
- <div id="content">
- <h:panelGrid class="table" columns="4">
- <h:column class="table_header_column">Bestellen?</h:column>
- <h:column class="table_header_column">Anzahl:</h:column>
- <h:column class="table_header_column">Produkt:</h:column>
- <h:column class="table_header_column">Einzelpreis:</h:column>
- </h:panelGrid>
-
- <%
- // Get app instance
- PizzaApplication app = PizzaServiceApplication.getInstance(application);
-
- // 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();
-
- // 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 ...
- %>
- <h:panelGrid class="table" columns="4">
- <h:column class="table_header_column"><a href="#{path}/basket.jsp" title="Zum Warenkorb">Warenkorb</a></h:column>
- <h:column class="table_header_column"><%=item.getAmount()%></h:column>
- <h:column class="table_header_column"><%=product.getTitle()%></h:column>
- <h:column class="table_header_column"><f:convertNumber type="currency"><%=product.getPrice()%></f:convertNumber></h:column>
- </h:panelGrid>
- <%
- // Then skip this item
- continue;
- }
-
- // Unmark as ordered
- app.unmarkProductAsOrdered(product, session);
- %>
- <h:form>
- <h:panelGrid class="table" columns="4">
- <h:column class="table_header_column">
- <h:commandButton action="#{path}/form_handler/add_item.jsp" class="submit" value="Hinzufü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" />
- </h:column>
- <h:column class="table_header_column">
- <!--<h:inputText class="input" size="3" maxlength="20" />-->
- <input class="input" type="text" name="<%=PizzaApplication.HTTP_PARAM_AMOUNT%>" size="3" maxlength="20" />
- </h:column>
- <h:column class="table_header_column">
- <%=product.getTitle()%>
- </h:column>
- <h:column class="table_header_column right">
- <f:convertNumber type="currency"><%=product.getPrice()%></f:convertNumber>
- </h:column>
- </h:panelGrid>
- </h:form>
- <%
- }
- %>
- </div>
- </div>
-
- <ui:include src="/static/guest/guest_footer.xhtml" id="footer" />
-
- </h:body>
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://xmlns.jcp.org/jsf/html"
+ xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
+ xmlns:f="http://xmlns.jcp.org/jsf/core"
+ >
+
+ <!--
+ TODO: Not used:
+ xmlns:basket="http://mxchange.org/jshop/tags/basket"
+ //-->
+
+ <ui:composition template="/WEB-INF/templates/guest/guest_base.tpl">
+ <ui:define name="title">Willkommen!</ui:define>
+
+ <ui:define name="menu">
+ <ui:include id="menu" class="guest_menu" src="/WEB-INF/templates/guest/guest_menu.tpl" />
+ </ui:define>
+
+ <ui:define name="content_header">
+ Eingangsseite (dummy)
+ </ui:define>
+
+ <ui:define name="content">
+ <!--
+ TODO Not used!
+ <h:panelGrid class="basket_item_table" columnClasses="table_data_column" headerClass="table_header_column">
+ <f:facet name="header">
+ Bestellen? Bestellmenge: Produkt: Einzelpreis:
+ </f:facet>
+ </h:panelGrid>
+ //-->
+
+ <h:form acceptcharset="utf-8" id="add_item">
+ <table class="basket_item_table">
+ <thead>
+ <tr>
+ <th colspan="5" class="table_header">
+ Folgendes kann bestellt werden:
+ </th>
+ </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>
+
+ <th class="table_header_column">
+ Zwischensumme:
+ </th>
+ </tr>
+ </thead>
+
+ <tbody>
+ <ui:repeat var="product" value="#{controller.availableProducts}">
+ <!-- Cache isAdded call to reduce calls //-->
+ <c:set var="isAdded" value="#{basket.isAdded(product)}" />
+
+ <ui:fragment rendered="#{isAdded == true}">
+ <tr>
+ <td class="table_data_column">
+ <h:link outcome="basket" title="Zum Warenkorb" value="Warenkorb" />
+ </td>
+
+ <td class="table_data_column">
+ #{basket.item.amount}
+ </td>
+
+ <td class="table_data_column">
+ #{product.title}
+ </td>
+
+ <td class="table_data_column" align="right">
+ <h:outputText class="price" value="#{product.price}">
+ <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" />
+ </h:outputText>
+ </td>
+
+ <td class="table_data_column" align="right">
+ <h:outputText class="price" value="#{basket.item.calculateTotalPrice()}">
+ <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" />
+ </h:outputText>
+ </td>
+ </tr>
+ </ui:fragment>
+
+ <ui:fragment rendered="#{isAdded == false}">
+ <tr>
+ <td class="table_data_column">
+ <h:commandButton class="submit" id="add" value="Hinzufügen" action="#{basket.addToBasket(product)}" />
+ <h:inputHidden id="itemId" value="#{product.itemId}" />
+ <h:inputHidden id="itemType" value="Product" />
+ </td>
+
+ <td class="table_data_column">
+ <h:inputText class="input" id="amount" size="3" maxlength="20">
+ <!--
+ If the customer wants to order more, he need to call in.
+ //-->
+ <f:validateLongRange minimum="1" maximum="10" />
+ </h:inputText>
+ </td>
+
+ <td class="table_data_column">
+ #{product.title}
+ </td>
+
+ <td class="table_data_column" align="right">
+ <h:outputText class="price" value="#{product.price}">
+ <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" />
+ </h:outputText>
+ </td>
+
+ <td class="table_data_column" align="right">
+ -
+ </td>
+ </tr>
+ </ui:fragment>
+ </ui:repeat>
+ </tbody>
+ </table>
+ </h:form>
+ </ui:define>
+
+ <ui:define name="footer">
+ <ui:include id="footer" class="guest_footer" src="/WEB-INF/templates/guest/guest_footer.tpl" />
+ </ui:define>
+ </ui:composition>
</html>