]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
updated jshop+ got rid of another (large) scriptlet
authorRoland Haeder <roland@mxchange.org>
Mon, 31 Aug 2015 07:25:19 +0000 (09:25 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 31 Aug 2015 07:28:33 +0000 (09:28 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

lib/jshop.jar
src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java
web/index.jsp

index b7b2cbcb4e9e1f61f7e12315a169aaa65d34036c..5aa5fc1dd179508c3875aec14c3435f7f095e326 100644 (file)
Binary files a/lib/jshop.jar and b/lib/jshop.jar differ
index 38ecddb5723943d78f0c430ed252570eba152bf2..a283f8d60169ad9dd44d2ed1463be21a04e97cfd 100644 (file)
@@ -44,12 +44,12 @@ public interface PizzaApplication extends Application {
        public static final String HTTP_PARAM_AMOUNT = "amount"; //NOI18N
 
        /**
-        * HTTP parameter "item_id"
+        * HTTP parameter "itemId"
         */
        public static final String HTTP_PARAM_ITEM_ID = "itemId"; //NOI18N
 
        /**
-        * HTTP parameter "type"
+        * HTTP parameter "itemType"
         */
        public static final String HTTP_PARAM_ITEM_TYPE = "itemType"; //NOI18N
 
index f1ffc9a3a639b63074590c390f8adeec31d15e5f..705f81bbafb3167db4be62a7480dc9e81f0c6643 100644 (file)
                                        </tr>
                                </table>
 
-                               <%
-                               // Get Iterator
-                               Iterator<Product> iterator = controller.getAvailableProducts();
-
-                               // "Walk" through all products and unmark them as ordered
-                               while (iterator.hasNext()) {
-                                       // Get product instance
-                                       Product product = iterator.next();
-
-                                       // Debug message
-                                       controller.getLogger().debug("product=" + product);
-
-                                       // Create an item instance form this product
-                                       AddableBasketItem item = controller.getBasket().getItem(product);
-
-                                       // Debug message
-                                       controller.getLogger().debug("item=" + item);
-
-                                       // Has it been already added to the basket?
-                                       if (item != null) {
-                                               // Item was added to basket
-                                               %>
-                                               <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.getAmount()%>
-                                                                               </td>
-                                                                               <td class="table_data_column">
-                                                                                       <%=product.getTitle()%>
-                                                                               </td>
-                                                                               <td class="table_data_column" align="right">
-                                                                                       <fmt:formatNumber type="currency" minFractionDigits="2" maxFractionDigits="2" value="<%=product.getPrice()%>" />
-                                                                               </td>
-                                                                       </tr>
-                                                       </tbody>
-                                               </table>
-                                               <%
-                                       } else {
-                                               %>
-                                               <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="<%=PizzaApplication.HTTP_PARAM_ITEM_ID%>" value="<%=product.getItemId()%>" />
-                                                                                       <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" minFractionDigits="2" maxFractionDigits="2" value="<%=product.getPrice()%>" />
-                                                                               </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&uuml;gen" />
+                                                                                               <input type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_ID%>" value="${product.itemId}" />
+                                                                                               <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.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>