From 481fca14e3e4dd31d33a891c667c77653fbe81b9 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 11 Aug 2015 11:01:21 +0200 Subject: [PATCH] =?utf8?q?Introduced=20new=20"getter"=20+=20moved=20div=20?= =?utf8?q?tag=20to=20menu.jsp=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../application/PizzaApplication.java | 15 ++++++++++ .../application/PizzaServiceApplication.java | 30 +++++++++++++++++++ web/bye.jsp | 4 +-- web/errorHandler.jsp | 4 +-- web/finished.jsp | 4 +-- web/form_handler/order.jsp | 4 +-- web/index.jsp | 17 ++--------- web/preview.jsp | 15 ++-------- web/static/menu.jsp | 14 +++++---- 9 files changed, 62 insertions(+), 45 deletions(-) diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java index 42b02c8f..8d16f755 100644 --- a/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java +++ b/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java @@ -194,4 +194,19 @@ public interface PizzaApplication extends Application { * @param value Value to set */ public void setValueInSession (final HttpSession session, final String key, final Object value); + + /** + * Some "getter" for a an array of unmarked products + * + * @param session HttpSession instance + * @return Unmarked products + */ + public Product[] getUnmarkedProducts (final HttpSession session); + + /** + * Some "getter" for a an array of all products + * + * @return Unmarked products + */ + public Product[] getProducts (); } diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java index df6cf192..2da95069 100644 --- a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java +++ b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java @@ -1038,4 +1038,34 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P // Return actual value return this.convertNullToEmpty(value); } + + /** + * Gets an array of products from product iterator and unmarks them as ordered + * + * @param session HttpSession instance + * @return Unmarked products + */ + @Override + public Product[] getUnmarkedProducts (final HttpSession session) { + // Init array + Product[] array = this.getProducts(); + + // Unmark are all as ordered + for (final Product product : array) { + this.unmarkProductAsOrdered(product, session); + } + + // Return finished array + return array; + } + + /** + * Some "getter" for a an array of all products + * + * @return Unmarked products + */ + @Override + public Product[] getProducts () { + return (Product[]) this.products.values().toArray(); + } } diff --git a/web/bye.jsp b/web/bye.jsp index acf5b790..b4a152f1 100644 --- a/web/bye.jsp +++ b/web/bye.jsp @@ -20,9 +20,7 @@

<%=PizzaServiceApplication.MAIN_TITLE%> - Sitzung beenden

- +
diff --git a/web/errorHandler.jsp b/web/errorHandler.jsp index 0f45fade..8fe26c1b 100644 --- a/web/errorHandler.jsp +++ b/web/errorHandler.jsp @@ -28,9 +28,7 @@

<%=PizzaServiceApplication.MAIN_TITLE%> - Fehler

- +
diff --git a/web/finished.jsp b/web/finished.jsp index 2ad0f23a..f8054014 100644 --- a/web/finished.jsp +++ b/web/finished.jsp @@ -35,9 +35,7 @@

<%=PizzaServiceApplication.MAIN_TITLE%> - Vielen Dank!

- +
diff --git a/web/form_handler/order.jsp b/web/form_handler/order.jsp index 6ddf7e7c..e00ec747 100644 --- a/web/form_handler/order.jsp +++ b/web/form_handler/order.jsp @@ -40,9 +40,7 @@

<%=PizzaServiceApplication.MAIN_TITLE%> - Form-Handler

- +
diff --git a/web/index.jsp b/web/index.jsp index d293fa26..b72daf9a 100644 --- a/web/index.jsp +++ b/web/index.jsp @@ -29,9 +29,7 @@

<%=PizzaServiceApplication.MAIN_TITLE%> - Eingangsseite

- +
@@ -60,17 +58,8 @@ <% - // Get iterator from products - Iterator> iterator = app.getProductsIterator(); - - // Iterate over all - while (iterator.hasNext()) { - // Get entry - Map.Entry entry = iterator.next(); - - // Get product - Product product = entry.getValue(); - app.unmarkProductAsOrdered(product, session); + // Much smaller loop + for (final Product product : app.getUnmarkedProducts(session)) { %> diff --git a/web/preview.jsp b/web/preview.jsp index 22f8e7e8..86d3832e 100644 --- a/web/preview.jsp +++ b/web/preview.jsp @@ -34,9 +34,7 @@

<%=PizzaServiceApplication.MAIN_TITLE%> - Bestellung anzeigen

- +
@@ -67,16 +65,7 @@ <% - // Get iterator from products - Iterator> iterator = app.getProductsIterator(); - - // Iterate over all - while (iterator.hasNext()) { - // Get entry - Map.Entry entry = iterator.next(); - - // Get product - Product product = entry.getValue(); + for (final Product product : app.getProducts()) { %> diff --git a/web/static/menu.jsp b/web/static/menu.jsp index 8136267b..c022e151 100644 --- a/web/static/menu.jsp +++ b/web/static/menu.jsp @@ -4,9 +4,11 @@ Author : Roland Haeder --%> - + -- 2.39.5