]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Now that instance product has no method to mark it as choosen (bad idea as all users...
authorRoland Haeder <roland@mxchange.org>
Tue, 11 Aug 2015 09:22:13 +0000 (11:22 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 11 Aug 2015 09:22:13 +0000 (11:22 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java
src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java
web/preview.jsp

index 4f3ca4af20dbd805f711eafe938201675adaf6ed..93d0d933eb30192c3d9c2e86cbe655641ca949cd 100644 (file)
@@ -160,6 +160,14 @@ public interface PizzaApplication extends Application {
         */
        public void markProductAsOrdered(final Product product, final HttpSession session);
 
+       /**
+        * Marks given product as choosen in session
+        *
+        * @param product Product to mark as ordered
+        * @param session Session instance
+        */
+       public void markProductAsChoosen(final Product product, final HttpSession session);
+
        /**
         * Unmarks given product as ordered in session
         *
index 5a834938e5b52b40a8d8a52d289f2619f2bc343e..647ab17969d945a8a9ad13845011632fb8d9a81e 100644 (file)
@@ -1030,4 +1030,32 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
        public Product[] getProducts () {
                return (Product[]) this.products.values().toArray();
        }
+
+       /**
+        * Marks given product as choosen in session
+        *
+        * @param product Product to mark as ordered
+        * @param session Session instance
+        */
+       @Override
+       public void markProductAsChoosen(final Product product, final HttpSession session) {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("product={0},session={1} - CALLED!", product, session)); //NOI18N
+
+               // Is product and session set?
+               if (product == null) {
+                       // Not set
+                       throw new NullPointerException("product is null"); //NOI18N
+               } else if (session == null) {
+                       // Not set
+                       throw new NullPointerException("session is null"); //NOI18N
+               }
+
+               // Mark it as ordered by setting flag
+               this.getLogger().debug(MessageFormat.format("Marking product={0} as choosen.", product.getName())); //NOI18N
+               this.setValueInSession(product, session, HTTP_PARAM_CHOOSE, "1");
+
+               // Trace message
+               this.getLogger().trace("EXIT!"); //NOI18N
+       }
 }
index 86d3832e5222a404756dca00a2c6b289480721a8..7002f658c191033e57cf366deb5ed76717634de2 100644 (file)
@@ -65,7 +65,8 @@
                                        </thead>
                                        <tbody class="table_body">
                                                <%
-                                               for (final Product product : app.getProducts()) {
+                                               // "Walk" through all products and unmark them as ordered
+                                               for (final Product product : app.getUnmarkedProducts(session)) {
                                                        %>
                                                        <tr>
                                                                <td>
@@ -88,8 +89,7 @@
                                                        // Is it choosen and amount set?
                                                        if (app.isProductChoosen(product, request, session)) {
                                                                // Then mark it as choosen
-                                                               product.markAsChoosen();
-                                                               app.unmarkProductAsOrdered(product, session);
+                                                               app.markProductAsChoosen(product, session);
                                                        }
                                                }
                                                %>