]> git.mxchange.org Git - pizzaservice-war.git/blob - web/index.xhtml
Converted private constructor to public init() method with context, still this cannot...
[pizzaservice-war.git] / web / index.xhtml
1 <?xml version='1.0' encoding='UTF-8' ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html"
4           xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
5           xmlns:f="http://xmlns.jcp.org/jsf/core">
6         <ui:param name="path" value="#{request.contextPath}" />
7         <h:head>
8                 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
9                 <link rel="stylesheet" href="#{path}/style.css" type="text/css"/>
10                 <title>Willkommen</title>
11         </h:head>
12         <h:body>
13                 <div id="header"> 
14                         <div id="title">
15                                 <h1>Willkommen</h1>
16                         </div>
17                 </div>
18
19                 <ui:include src="/static/guest/guest_menu.xhtml" id="menu" />
20
21                 <div id="content_outer">
22                         <div id="content_title">
23                                 <h2>Folgendes kann bestellt werden:</h2>
24                         </div>
25
26                         <div id="content">
27                                 <h:panelGrid class="table" columns="4">
28                                         <h:column class="table_header_column">Bestellen?</h:column>
29                                         <h:column class="table_header_column">Anzahl:</h:column>
30                                         <h:column class="table_header_column">Produkt:</h:column>
31                                         <h:column class="table_header_column">Einzelpreis:</h:column>
32                                 </h:panelGrid>
33
34                                 <%
35                                 // Get app instance
36                                 PizzaApplication app = PizzaServiceApplication.getInstance(application);
37
38                                 // Get Iterator
39                                 Iterator<Product> iterator = app.getAvailableProducts();
40
41                                 // "Walk" through all products and unmark them as ordered
42                                 while (iterator.hasNext()) {
43                                         // Get product instance
44                                         Product product = iterator.next();
45
46                                         // Get basket instance
47                                         Basket<AddableBasketItem> basket = ItemBasket.getInstance(session);
48
49                                         // Create an item instance form this product
50                                         AddableBasketItem item = basket.getItem(product);
51
52                                         // Has it been already added to the basket?
53                                         if (item != null) {
54                                                 // Some nice output ...
55                                                 %>
56                                 <h:panelGrid class="table" columns="4">
57                                         <h:column class="table_header_column"><a href="#{path}/basket.jsp" title="Zum Warenkorb">Warenkorb</a></h:column>
58                                         <h:column class="table_header_column"><%=item.getAmount()%></h:column>
59                                         <h:column class="table_header_column"><%=product.getTitle()%></h:column>
60                                         <h:column class="table_header_column"><f:convertNumber type="currency"><%=product.getPrice()%></f:convertNumber></h:column>
61                                 </h:panelGrid>
62                                                 <%
63                                                 // Then skip this item
64                                                 continue;
65                                         }
66
67                                         // Unmark as ordered
68                                         app.unmarkProductAsOrdered(product, session);
69                                         %>
70                                 <h:form>
71                                 <h:panelGrid class="table" columns="4">
72                                         <h:column class="table_header_column">
73                                                 <h:commandButton action="#{path}/form_handler/add_item.jsp" class="submit" value="Hinzuf&uuml;gen" />
74                                                 <input class="input" type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_ID%>" value="<%=product.getId()%>" />
75                                                 <input class="input" type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_TYPE%>" value="Product" />
76                                         </h:column>
77                                         <h:column class="table_header_column">
78                                                 <!--<h:inputText class="input" size="3" maxlength="20" />-->
79                                                 <input class="input" type="text" name="<%=PizzaApplication.HTTP_PARAM_AMOUNT%>" size="3" maxlength="20" />
80                                         </h:column>
81                                         <h:column class="table_header_column">
82                                                 <%=product.getTitle()%>
83                                         </h:column>
84                                         <h:column class="table_header_column right">
85                                                 <f:convertNumber type="currency"><%=product.getPrice()%></f:convertNumber>
86                                         </h:column>
87                                 </h:panelGrid>
88                                 </h:form>
89                                 <%
90                         }
91                         %>
92                         </div>
93                 </div>
94
95                 <ui:include src="/static/guest/guest_footer.xhtml" id="footer" />
96
97         </h:body>
98 </html>