]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Continued with project:
authorRoland Haeder <roland@mxchange.org>
Thu, 13 Aug 2015 07:37:43 +0000 (09:37 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 13 Aug 2015 13:35:40 +0000 (15:35 +0200)
- Added menu item (and JSP) for categories
- Renamed JSP to get rid of plural
- Started with refactoring of application, the whole product (and now category) list would be kept in RAM which is far to much wasting
- Got rid of getUnmarkedProducts(), better use generic getProducts()
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
src/java/org/mxchange/pizzaapplication/category/Category.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/product/PizzaProduct.java
src/java/org/mxchange/pizzaapplication/product/Product.java
web/admin/category.jsp [new file with mode: 0644]
web/admin/product.jsp [new file with mode: 0644]
web/admin/products.jsp [deleted file]
web/index.jsp
web/preview.jsp
web/static/admin/menu.jsp

index 3c31ab0863248743b931928ecd05f45edecbe1c0..3e2a6a3951afbbe50917802f299fe9f9df60ff80 100644 (file)
@@ -19,6 +19,7 @@ package org.mxchange.pizzaapplication.application;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 import org.mxchange.jcore.application.Application;
+import org.mxchange.pizzaapplication.category.Category;
 import org.mxchange.pizzaapplication.product.Product;
 
 /**
@@ -193,19 +194,18 @@ public interface PizzaApplication extends Application {
        public void setValueInSession (final HttpSession session, final String key, final Object value);
 
        /**
-        * Some "getter" for a an array of unmarked products
+        * Some "getter" for a an array of all products
         * 
-        * @param session HttpSession instance
-        * @return Unmarked products
+        * @return All products
         */
-       public Product[] getUnmarkedProducts (final HttpSession session);
+       public Iterable<Product> getProducts ();
 
        /**
-        * Some "getter" for a an array of all products
-        * 
-        * @return Unmarked products
+        * Some "getter" for a an array of all categories
+        *
+        * @return All categories
         */
-       public Product[] getProducts ();
+       public Iterable<Category> getCategories ();
 
        /**
         * Checks if given Product instance is available and returns a printable
index 8a8adac8769b233946ed8f836a83839fd5e495d6..5b8c210ff656d7e00fb45e77bca73a6e0a5a21f7 100644 (file)
@@ -23,8 +23,6 @@ import java.sql.SQLException;
 import java.text.MessageFormat;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
@@ -33,6 +31,7 @@ import org.mxchange.jcore.contact.Gender;
 import org.mxchange.jcore.exceptions.BadTokenException;
 import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
 import org.mxchange.pizzaapplication.BasePizzaServiceSystem;
+import org.mxchange.pizzaapplication.category.Category;
 import org.mxchange.pizzaapplication.customer.Customer;
 import org.mxchange.pizzaapplication.customer.PizzaServiceCustomer;
 import org.mxchange.pizzaapplication.database.frontend.product.PizzaProductDatabaseFrontend;
@@ -49,6 +48,11 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
         */
        public static final String MAIN_TITLE = "Pizza-Service";
 
+       /**
+        * Frontend for products
+        */
+       private ProductFrontend productFrontend;
+
        /**
         * Some singleton getter for this instance. If the instance is not set in
         * given application, it will be created.
@@ -106,28 +110,12 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                new PizzaServiceApplication().start();
        }
 
-       /**
-        * Product list 
-        */
-       private final SortedMap<String, Product> products;
-
-       /**
-        * Private constructor
-        */
-       private PizzaServiceApplication () {
-               // Init products instance
-               this.products = new TreeMap<>();
-       }
-
        /**
         * Constructor with servet configuration
         *
         * @param context Servlet context
         */
        private PizzaServiceApplication (final ServletContext context) throws UnsupportedDatabaseBackendException, SQLException, IOException, BadTokenException {
-               // Call other constructor first
-               this();
-
                // Temporary initialize default bundle
                // @TODO The JSF may have better internatialization support
                this.initBundle();
@@ -135,8 +123,14 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                // Initialize properties from config
                this.initProperties(context);
 
-               // Load available products
-               this.fillProductsList();
+               // Init database frontends
+               this.initDatabaseFrontends();
+       }
+
+       /**
+        * Default constructor
+        */
+       private PizzaServiceApplication () {
        }
 
        /**
@@ -168,7 +162,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                        // Is this choosen?
                        if (this.isProductChoosen(product, request, session)) {
                                // Then add ordered amount
-                               this.getLogger().debug(MessageFormat.format("Counting {0} ...", product.getName())); //NOI18N
+                               this.getLogger().debug(MessageFormat.format("Counting {0} ...", product.getId())); //NOI18N
 
                                // Getting amount
                                String amount = this.getAmountFromSession(product, session);
@@ -177,7 +171,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                                this.getLogger().debug(MessageFormat.format("amount={0}", amount)); //NOI18N
                                totalAmount += Integer.valueOf(amount);
                        }
-                       this.getLogger().debug(MessageFormat.format("product={0},totalAmount={1}", product.getName(), totalAmount)); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("product={0},totalAmount={1}", product.getId(), totalAmount)); //NOI18N
                }
 
                // Trace message
@@ -216,10 +210,10 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                        // Is this choosen?
                        if (this.isProductChoosen(product, request, session)) {
                                // Then add product's total price
-                               this.getLogger().debug(MessageFormat.format("Calling getTotalPositionPriceFromRequestSession({0},request,session) ...", product.getName())); //NOI18N
+                               this.getLogger().debug(MessageFormat.format("Calling getTotalPositionPriceFromRequestSession({0},request,session) ...", product.getId())); //NOI18N
                                totalPrice += this.getTotalPositionPriceFromRequestSession(product, request, session);
                        }
-                       this.getLogger().debug(MessageFormat.format("product={0},totalPrice={1}", product.getName(), totalPrice)); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("product={0},totalPrice={1}", product.getId(), totalPrice)); //NOI18N
                }
 
                // Trace message
@@ -352,7 +346,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                // Is the object null?
                if (object == null) {
                        // Not found
-                       this.getLogger().debug(MessageFormat.format("Returning empty string for product={0} ...", product.getName())); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("Returning empty string for product={0} ...", product.getId())); //NOI18N
                        return ""; //NOI18N
                }
 
@@ -426,9 +420,9 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                }
 
                // Get element
-               this.getLogger().debug(MessageFormat.format("Calling handleChooseFromRequestSession({0},{1},{2}) ...", product.getName(), request, session)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("Calling handleChooseFromRequestSession({0},{1},{2}) ...", product.getId(), request, session)); //NOI18N
                String choosen = this.handleChooseFromRequestSession(product, request, session);
-               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getName(), choosen)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getId(), choosen)); //NOI18N
 
                // Must not be null
                assert(choosen instanceof String): "choosen is null"; //NOI18N
@@ -441,7 +435,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
 
                // Get amount
                String amount = this.handleAmountFromRequestSession(product, request, session);
-               this.getLogger().debug(MessageFormat.format("product={0},amount={1}", product.getName(), amount)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("product={0},amount={1}", product.getId(), amount)); //NOI18N
 
                // Must not be null
                assert(amount instanceof String): "amount is null"; //NOI18N
@@ -505,11 +499,21 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
        /**
         * Some "getter" for a an array of all products
         *
-        * @return Unmarked products
+        * @return All products
         */
        @Override
-       public Product[] getProducts () {
-               return this.products.values().toArray(new Product[this.products.size()]);
+       public Iterable<Product> getProducts () {
+               throw new UnsupportedOperationException("Needs refacturing ...");
+       }
+
+       /**
+        * Some "getter" for a an array of all categories
+        *
+        * @return All categories
+        */
+       @Override
+       public Iterable<Category> getCategories () {
+               throw new UnsupportedOperationException("Needs refacturing ...");
        }
 
        /**
@@ -539,9 +543,9 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                }
 
                // Get choosen
-               this.getLogger().debug(MessageFormat.format("Calling handleChooseFromRequestSession({0},{1},{2}) ...", product.getName(), request, session)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("Calling handleChooseFromRequestSession({0},{1},{2}) ...", product.getId(), request, session)); //NOI18N
                String choosen = this.handleChooseFromRequestSession(product, request, session);
-               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getName(), choosen)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getId(), choosen)); //NOI18N
 
                // Must not be null
                assert(choosen instanceof String): "choosen is null"; //NOI18N
@@ -549,13 +553,13 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                // Is it set?
                if (choosen.isEmpty()) {
                        // Is empty
-                       this.getLogger().debug(MessageFormat.format("product={0},choosen={1} - returning zero ...", product.getName(), choosen)); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("product={0},choosen={1} - returning zero ...", product.getId(), choosen)); //NOI18N
                        return 0.00f;
                }
 
                // Get amount
                String amount = this.handleAmountFromRequestSession(product, request, session);
-               this.getLogger().debug(MessageFormat.format("product={0},amount={1}", product.getName(), amount)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("product={0},amount={1}", product.getId(), amount)); //NOI18N
 
                // Must not be null
                assert(amount instanceof String): "amount is null"; //NOI18N
@@ -563,7 +567,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                // Is it empty?
                if (amount.isEmpty() || "0".equals(amount)) { //NOI18N
                        // Is empty
-                       this.getLogger().debug(MessageFormat.format("product={0},amount={1} - returning zero ...", product.getName(), amount)); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("product={0},amount={1} - returning zero ...", product.getId(), amount)); //NOI18N
                        return 0.00f;
                }
 
@@ -583,32 +587,12 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                float price = (product.getPrice() * value);
 
                // Trace message
-               this.getLogger().trace(MessageFormat.format("product={0},price={1} - EXIT!", product.getName(), price)); //NOI18N
+               this.getLogger().trace(MessageFormat.format("product={0},price={1} - EXIT!", product.getId(), price)); //NOI18N
 
                // Then multiply it with price
                return price;
        }
 
-       /**
-        * 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;
-       }
-
        /**
         * Handler for amount from request or session
         *
@@ -644,12 +628,12 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                } else if (this.handleChooseFromRequestSession(product, request, session).isEmpty()) {
                        // Not choosen
                        this.clearSessionAttribute(product, session, HTTP_PARAM_AMOUNT);
-                       this.getLogger().debug(MessageFormat.format("Unsetting for product={0} in session, returning zero ...", product.getName())); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("Unsetting for product={0} in session, returning zero ...", product.getId())); //NOI18N
                        return "0"; //NOI18N
                }
 
                // Get attribute from request
-               object = request.getParameter(String.format(HTTP_PARAM_MASK, HTTP_PARAM_AMOUNT, product.getName()));
+               object = request.getParameter(String.format(HTTP_PARAM_MASK, HTTP_PARAM_AMOUNT, product.getId()));
 
                // Is it set?
                if (object instanceof String) {
@@ -702,9 +686,9 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                }
 
                // Get choosen
-               this.getLogger().debug(MessageFormat.format("Calling handleChooseFromRequestSession({0},{1},{2}) ...", product.getName(), request, session)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("Calling handleChooseFromRequestSession({0},{1},{2}) ...", product.getId(), request, session)); //NOI18N
                String choosen = this.handleChooseFromRequestSession(product, request, session);
-               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getName(), choosen)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getId(), choosen)); //NOI18N
 
                // Must not be null
                assert(choosen instanceof String): "choosen is null"; //NOI18N
@@ -749,7 +733,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                }
 
                // Mark it as ordered by setting flag
-               this.getLogger().debug(MessageFormat.format("Marking product={0} as choosen.", product.getName())); //NOI18N
+               this.getLogger().debug(MessageFormat.format("Marking product={0} as choosen.", product.getId())); //NOI18N
                this.setValueInSession(product, session, HTTP_PARAM_CHOOSE, "1"); //NOI18N
 
                // Trace message
@@ -777,7 +761,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                }
 
                // Mark it as ordered by setting flag
-               this.getLogger().debug(MessageFormat.format("Marking product={0} as ordered.", product.getName())); //NOI18N
+               this.getLogger().debug(MessageFormat.format("Marking product={0} as ordered.", product.getId())); //NOI18N
                this.setValueInSession(product, session, SESSION_ORDERED, "true"); //NOI18N
 
                // Trace message
@@ -826,7 +810,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                }
 
                // Mark it as ordered by setting flag
-               this.getLogger().debug(MessageFormat.format("Unmarking product={0} as choosen.", product.getName())); //NOI18N
+               this.getLogger().debug(MessageFormat.format("Unmarking product={0} as choosen.", product.getId())); //NOI18N
                this.clearSessionAttribute(product, session, HTTP_PARAM_CHOOSE);
 
                // Trace message
@@ -854,41 +838,13 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                }
 
                // Mark it as ordered by setting flag
-               this.getLogger().debug(MessageFormat.format("Unmarking product={0} as ordered.", product.getName())); //NOI18N
+               this.getLogger().debug(MessageFormat.format("Unmarking product={0} as ordered.", product.getId())); //NOI18N
                this.clearSessionAttribute(product, session, SESSION_ORDERED);
 
                // Trace message
                this.getLogger().trace("EXIT!"); //NOI18N
        }
 
-       /**
-        * Adds given product to list or throws an exception if name is already found
-        *
-        * @param product Product instance to add
-        */
-       private void addProduct (final Product product) {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product)); //NOI18N
-
-               // Get all data from it
-               String name = product.getName();
-
-               // Is the name already used?
-               if (this.isProductNameUsed(name)) {
-                       // Something went wrong
-                       throw new IllegalArgumentException(MessageFormat.format("product {0} is already used.", name)); //NOI18N
-               }
-
-               // Debug message
-               this.getLogger().debug(MessageFormat.format("Adding product={0} ...", product)); //NOI18N
-
-               // Add it
-               this.products.put(product.getName(), product);
-
-               // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
-       }
-
        /**
         * Clears given parameter for product in session
         *
@@ -901,40 +857,13 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("produce={0},parameter={1},session={2} - CALLED!", product, parameter, session)); //NOI18N
 
                // Clear in session
-               this.getLogger().debug(MessageFormat.format("Clearing product={0},parameter={1} ...", product.getName(), parameter)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("Clearing product={0},parameter={1} ...", product.getId(), parameter)); //NOI18N
                this.setValueInSession(product, session, parameter, null);
 
                // Trace message
                this.getLogger().trace("EXIT!"); //NOI18N
        }
 
-       /**
-        * Fills products list
-        * @todo Very hard-coded stuff ...
-        */
-       private void fillProductsList () throws UnsupportedDatabaseBackendException, SQLException, IOException, BadTokenException {
-               // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
-
-               // Get a product frontend
-               ProductFrontend frontend = new PizzaProductDatabaseFrontend();
-
-               // Get iterator
-               Iterator<Product> iterator = frontend.getProducts();
-
-               // Get all products
-               while (iterator.hasNext()) {
-                       // Get it
-                       Product product = iterator.next();
-
-                       // Add it
-                       this.addProduct(product);
-               }
-
-               // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
-       }
-
        /**
         * Some getter for value from session
         *
@@ -948,9 +877,9 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0},session={1},attribute={2} - CALLED!", product, session, attribute)); //NOI18N
 
                // Init variable
-               Object value = this.getValueFromSession(session, String.format(HTTP_PARAM_MASK, attribute, product.getName()));
+               Object value = this.getValueFromSession(session, String.format(HTTP_PARAM_MASK, attribute, product.getId()));
                
-               this.getLogger().debug(MessageFormat.format("product={0},attribute={1},value={2}", product.getName(), attribute, value)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("product={0},attribute={1},value={2}", product.getId(), attribute, value)); //NOI18N
 
                // Trace message
                this.getLogger().trace(MessageFormat.format("value={0} - EXIT!", value)); //NOI18N
@@ -1015,26 +944,26 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                // Check request method
                if (!"POST".equals(request.getMethod())) { //NOI18N
                        // Not POST, so get from session
-                       this.getLogger().trace(MessageFormat.format("Calling this.getChooseFromSession({0},{1}) ... - EXIT!", product.getName(), session));
+                       this.getLogger().trace(MessageFormat.format("Calling this.getChooseFromSession({0},{1}) ... - EXIT!", product.getId(), session));
                        return this.getChooseFromSession(product, session);
                } else if (this.isProductOrdered(product, session)) {
                        // Product is ordered
-                       this.getLogger().trace(MessageFormat.format("Calling this.getChooseFromSession({0},{1}) ... - EXIT!", product.getName(), session));
+                       this.getLogger().trace(MessageFormat.format("Calling this.getChooseFromSession({0},{1}) ... - EXIT!", product.getId(), session));
                        return this.getChooseFromSession(product, session);
                } else if (!this.getChooseFromSession(product, session).isEmpty()) {
                        // Found in session
-                       this.getLogger().trace(MessageFormat.format("Calling this.getChooseFromSession({0},{1}) ... - EXIT!", product.getName(), session));
+                       this.getLogger().trace(MessageFormat.format("Calling this.getChooseFromSession({0},{1}) ... - EXIT!", product.getId(), session));
                        return this.getChooseFromSession(product, session);
                }
 
                // Get reqzest element
-               object = request.getParameter(String.format(HTTP_PARAM_MASK, HTTP_PARAM_CHOOSE, product.getName()));
-               this.getLogger().debug(MessageFormat.format("product={0},object={1}", product.getName(), object)); //NOI18N
+               object = request.getParameter(String.format(HTTP_PARAM_MASK, HTTP_PARAM_CHOOSE, product.getId()));
+               this.getLogger().debug(MessageFormat.format("product={0},object={1}", product.getId(), object)); //NOI18N
 
                // Is it null?
                if (object == null) {
                        // Unset session
-                       this.getLogger().debug(MessageFormat.format("Unsetting session for product={0} ...", product.getName())); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("Unsetting session for product={0} ...", product.getId())); //NOI18N
                        this.clearSessionAttribute(product, session, HTTP_PARAM_CHOOSE);
                        this.clearSessionAttribute(product, session, HTTP_PARAM_AMOUNT);
 
@@ -1046,29 +975,22 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.setValueInSession(product, session, HTTP_PARAM_CHOOSE, object);
 
                // Cast to string and return it
-               this.getLogger().debug(MessageFormat.format("product={0} - Returning {1} ...", product.getName(), object)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("product={0} - Returning {1} ...", product.getId(), object)); //NOI18N
                return (String) object;
        }
 
        /**
-        * Checks whether given product is already used
-        *
-        * @param name Name of product
-        * @return Whether the given product's name is already used
+        * Initializes database frontends.
         */
-       private boolean isProductNameUsed(final String name) {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("name={0} - CALLED!", name)); //NOI18N
-
-               // Is it found?
-               return this.products.containsKey(name);
+       private void initDatabaseFrontends () throws UnsupportedDatabaseBackendException, SQLException {
+               this.productFrontend = new PizzaProductDatabaseFrontend();
        }
 
        /**
         * Checks if the product ordered?
         *
-        * @param product
-        * @param session
+        * @param product Product instance
+        * @param session HttpSession instance
         * @return
         */
        private boolean isProductOrdered(final Product product, final HttpSession session) {
@@ -1077,7 +999,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
 
                // Get session
                Object isOrdered = this.getValueFromSession(product, session, SESSION_ORDERED);
-               this.getLogger().debug(MessageFormat.format("product={0},isOrdered={1}", product.getName(), isOrdered)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("product={0},isOrdered={1}", product.getId(), isOrdered)); //NOI18N
 
                // Return result
                return ("true".equals(isOrdered)); //NOI18N
@@ -1096,8 +1018,8 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0},session={1},keyPart={2},value={3} - CALLED!", product, session, keyPart, value)); //NOI18N
 
                // Set it synced
-               this.getLogger().debug(MessageFormat.format("Setting value={0} for product={1},keyPart={2}", value, product.getName(), keyPart)); //NOI18N
-               this.setValueInSession(session, String.format(HTTP_PARAM_MASK, keyPart, product.getName()), value);
+               this.getLogger().debug(MessageFormat.format("Setting value={0} for product={1},keyPart={2}", value, product.getId(), keyPart)); //NOI18N
+               this.setValueInSession(session, String.format(HTTP_PARAM_MASK, keyPart, product.getId()), value);
 
                // Trace message
                this.getLogger().trace("EXIT!"); //NOI18N
@@ -1113,10 +1035,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                try {
                        // Init properties
                        this.initProperties();
-
-                       // Fill products list
-                       this.fillProductsList();
-               } catch (final IOException | UnsupportedDatabaseBackendException | SQLException | BadTokenException ex) {
+               } catch (final IOException ex) {
                        // Abort here
                        this.abortProgramWithException(ex);
                }
@@ -1124,7 +1043,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                // "Walk" over all products
                for (final Product product : this.getProducts()) {
                        // Output data
-                       this.getLogger().debug(MessageFormat.format("Product {0}, {1}: {2}", product.getName(), product.getTitle(), product.getPrice())); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("Product {0}, {1}: {2}", product.getId(), product.getTitle(), product.getPrice())); //NOI18N
                }
 
                // Generate fake Customer instance
diff --git a/src/java/org/mxchange/pizzaapplication/category/Category.java b/src/java/org/mxchange/pizzaapplication/category/Category.java
new file mode 100644 (file)
index 0000000..c1b0fdf
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.category;
+
+import org.mxchange.jcore.FrameworkInterface;
+
+/**
+ * An interface for categories
+ *
+ * @author Roland Haeder
+ */
+public interface Category extends FrameworkInterface {
+}
index 1f626b97b49fb7276f642acd851c795244807333..751aaea8a0c32f443aac99e19b56b2dc0cdfa683 100644 (file)
  */
 package org.mxchange.pizzaapplication.product;
 
+import org.mxchange.pizzaapplication.category.Category;
 import org.mxchange.jcore.BaseFrameworkSystem;
 
 /**
+ * Product class for pizza application
  *
  * @author Roland Haeder
  */
 public class PizzaProduct extends BaseFrameworkSystem implements Product {
        /**
-        * Name of product
+        * Product category
         */
-       private String name;
+       private Category category;
+
+       /**
+        * Id number of product
+        */
+       private Long id;
 
        /**
         * Price of product
@@ -41,31 +48,52 @@ public class PizzaProduct extends BaseFrameworkSystem implements Product {
        /**
         * Constructor for products with a name and a price.
         * 
-        * @param name Name of product
+        * @param id Id number of product
         * @param title Name of product
         * @param price Price
         */
-       public PizzaProduct (final String name, final String title, final float price) {
-               this.setName(name);
+       public PizzaProduct (final Long id, final String title, final float price) {
+               this.setId(id);
                this.setTitle(title);
                this.setPrice(price);
        }
 
+       /**
+        * Getter for product category
+        *
+        * @return Product category
+        */
+       @Override
+       public final Category getCategory () {
+               return this.category;
+       }
+
+       /**
+        * Setter for product category
+        *
+        * @param category Product category
+        */
+       @Override
+       public final void setCategory (final Category category) {
+               this.category = category;
+       }
+
        /**
         * Name of product
         * @return the name
         */
        @Override
-       public final String getName () {
-               return this.name;
+       public final Long getId () {
+               return this.id;
        }
 
        /**
-        * Name of product
-        * @param name the name to set
+        * Id number of product
+        * @param id the id number to set
         */
-       protected final void setName (final String name) {
-               this.name = name;
+       @Override
+       public final void setId (final Long id) {
+               this.id = id;
        }
 
        /**
@@ -81,7 +109,8 @@ public class PizzaProduct extends BaseFrameworkSystem implements Product {
         * Price of product
         * @param price the price to set
         */
-       protected final void setPrice (final float price) {
+       @Override
+       public final void setPrice (final float price) {
                this.price = price;
        }
 
@@ -98,7 +127,8 @@ public class PizzaProduct extends BaseFrameworkSystem implements Product {
         * Title of product
         * @param title the title to set
         */
-       protected final void setTitle (final String title) {
+       @Override
+       public final void setTitle (final String title) {
                this.title = title;
        }
 }
index bdeea227892a00402e564fbfb1987d9abccc62bc..6157ad6edbf2b43f225fe003a51641fc0d03f8f1 100644 (file)
@@ -16,6 +16,7 @@
  */
 package org.mxchange.pizzaapplication.product;
 
+import org.mxchange.pizzaapplication.category.Category;
 import org.mxchange.jcore.database.storage.Storeable;
 
 /**
@@ -24,11 +25,17 @@ import org.mxchange.jcore.database.storage.Storeable;
  */
 public interface Product extends Storeable {
        /**
-        * Getter for name, suitable for form fields.
+        * Getter for id number, suitable for form fields.
         * 
-        * @return Name of product
+        * @return Id number of product
         */
-       public String getName ();
+       public Long getId ();
+
+       /**
+        * Id number of product
+        * @param id the id number to set
+        */
+       public void setId (final Long id);
 
        /**
         * Getter for title.
@@ -37,10 +44,36 @@ public interface Product extends Storeable {
         */
        public String getTitle ();
 
+       /**
+        * Title of product
+        * @param title the title to set
+        */
+       public void setTitle (final String title);
+
        /**
         * Getter for raw price.
         * 
         * @return Single price of product
         */
        public float getPrice ();
+
+       /**
+        * Price of product
+        * @param price the price to set
+        */
+       public void setPrice (final float price);
+
+       /**
+        * Getter for product category
+        *
+        * @return Product category
+        */
+       public Category getCategory ();
+
+       /**
+        * Setter for product category
+        *
+        * @param category Product category
+        */
+       public void setCategory (final Category category);
 }
diff --git a/web/admin/category.jsp b/web/admin/category.jsp
new file mode 100644 (file)
index 0000000..1dc87c5
--- /dev/null
@@ -0,0 +1,141 @@
+<%-- 
+       Document   : category
+       Created on : 05.08.2015, 10:51:14
+       Author     : Roland Haeder
+--%>
+
+<%--<%@page errorPage="errorHandler.jsp" %>--%>
+<%@page import="org.mxchange.pizzaapplication.category.Category"%>
+<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
+<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+
+<%
+       // Init application instance
+       PizzaApplication app = PizzaServiceApplication.getInstance(application);
+%>
+
+<!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" xml:lang="de" lang="de">
+       <head>
+               <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+               <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
+               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Kategorien</title>
+       </head>
+
+       <body>
+               <div id="title">
+                       <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Kategorien</h1>
+               </div>
+
+               <jsp:include page="/static/admin/menu.jsp" flush="true" />
+
+               <div id="content_outer">
+                       <div id="content_title">
+                               <h2>Kategorien administrieren:</h2>
+                       </div>
+
+                       <div id="content">
+                               <div class="para">
+                                       <form action="<%=request.getContextPath()%>/form_handler/admin/do_category.jsp" accept-charset="utf-8" id="form" method="post">
+                                       <table class="table">
+                                               <thead class="table_header">
+                                                       <tr>
+                                                               <th class="table_header_column">
+                                                                       Produktname: (Schlüssel)
+                                                               </th>
+                                                               <th class="table_header_column">
+                                                                       Produktbezeichnung:
+                                                               </th>
+                                                               <th class="table_header_column">
+                                                                       Einzelpreis:
+                                                               </th>
+                                                       </tr>
+                                               </thead>
+
+                                               <tbody class="table_body">
+                                                       <%
+                                                       // "Walk" through all products and unmark them as ordered
+                                                       for (final Category category : app.getCategories()) {
+                                                               %>
+                                                               <tr>
+                                                                       <td>
+                                                                               <%=category.getId()%>
+                                                                       </td>
+                                                                       <td>
+                                                                               <%=category.getTitle()%>
+                                                                       </td>
+                                                                       <td>
+                                                                               <%=category.getPrice()%>
+                                                                       </td>
+                                                               </tr>
+                                                               <%
+                                                       }
+                                                       %>
+
+                                                       <tr>
+                                                               <td colspan="3" class="table_footer">
+                                                                       <input type="reset" value="Formular zurücksetzen" />
+                                                                       <input type="submit" name="edit" value="Ändern" />
+                                                                       <input type="submit" name="delete" value="Löschen" />
+                                                               </td>
+                                                       </tr>
+                                               </tbody>
+                                       </table>
+                                       </form>
+                               </div>
+
+                               <div class="para">
+                                       <form action="<%=request.getContextPath()%>/form_handler/admin/do_category.jsp" accept-charset="utf-8" id="add" method="post">
+                                       <div class="table">
+                                               <div class="table_header">
+                                                       Neue Kategorie hinzufügen:
+                                               </div>
+
+                                               <fieldset id="product_data">
+                                                       <legend>Bitte alle Felder ausfüllen:</legend>
+
+                                                       <div class="data_row">
+                                                               <div class="table_left">
+                                                                       Produktbezeichnung:
+                                                                       <div class="tiny">(z.B. <em>Pizza Italia</em>)</div>
+                                                               </div>
+
+                                                               <div class="table_right">
+                                                                       <input type="text" name="title" size="10" maxlength="255" />
+                                                               </div>
+
+                                                               <div class="clear"></div>
+                                                       </div>
+
+                                                       <div class="data_row">
+                                                               <div class="table_left">
+                                                                       Einzelpreis:
+                                                                       <div class="tiny">(z.B. <em>50.0</em>)</div>
+                                                               </div>
+
+                                                               <div class="table_right">
+                                                                       <input type="text" name="price" size="10" maxlength="255" />
+                                                               </div>
+
+                                                               <div class="clear"></div>
+                                                       </div>
+                                               </fieldset>
+
+                                               <div class="table_footer">
+                                                       <input type="reset" value="Formular zurücksetzen" />
+                                                       <input type="submit" name="add" value="Hinzufügen" />
+                                               </div>
+                                       </div>
+                                       </form>
+                               </div>
+                               <div class="para">
+                                       Hinweise zum Hinzufügen von Kategorien
+                                       <ul>
+                                               <li></li>
+                                       </ul>
+                               </div>
+                       </div>
+               </div>
+       </body>
+</html>
diff --git a/web/admin/product.jsp b/web/admin/product.jsp
new file mode 100644 (file)
index 0000000..1efbefe
--- /dev/null
@@ -0,0 +1,149 @@
+<%-- 
+       Document   : products
+       Created on : 04.08.2015, 10:55:10
+       Author     : Roland Haeder
+--%>
+
+<%--<%@page errorPage="errorHandler.jsp" %>--%>
+<%@page import="java.util.Iterator"%>
+<%@page import="java.util.Map"%>
+<%@page import="org.mxchange.jcore.contact.Gender"%>
+<%@page import="org.mxchange.pizzaapplication.product.Product"%>
+<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
+<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+
+<%
+       // Init application instance
+       PizzaApplication app = PizzaServiceApplication.getInstance(application);
+%>
+<!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" xml:lang="de" lang="de">
+       <head>
+               <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+               <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
+               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Bestellung anzeigen</title>
+       </head>
+
+       <body>
+               <div id="title">
+                       <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Bestellung anzeigen</h1>
+               </div>
+
+               <jsp:include page="/static/admin/menu.jsp" flush="true" />
+
+               <div id="content_outer">
+                       <div id="content_title">
+                               <h2>Diese Produkte wurden eingestellt:</h2>
+                       </div>
+
+                       <div id="content">
+                               <div class="para">
+                                       <form action="<%=request.getContextPath()%>/form_handler/admin/do_product.jsp" accept-charset="utf-8" id="form" method="post">
+                                       <table class="table">
+                                               <thead class="table_header">
+                                                       <tr>
+                                                               <th class="table_header_column">
+                                                                       Produktname: (Schlüssel)
+                                                               </th>
+                                                               <th class="table_header_column">
+                                                                       Produktbezeichnung:
+                                                               </th>
+                                                               <th class="table_header_column">
+                                                                       Einzelpreis:
+                                                               </th>
+                                                               <th class="table_header_column">
+                                                                       Verfügbarkeit:
+                                                               </th>
+                                                       </tr>
+                                               </thead>
+
+                                               <tbody class="table_body">
+                                                       <%
+                                                       // "Walk" through all products and unmark them as ordered
+                                                       for (final Product product : app.getProducts()) {
+                                                               %>
+                                                               <tr>
+                                                                       <td>
+                                                                               <%=product.getId()%>
+                                                                       </td>
+                                                                       <td>
+                                                                               <%=product.getTitle()%>
+                                                                       </td>
+                                                                       <td>
+                                                                               <%=product.getPrice()%>
+                                                                       </td>
+                                                                       <td>
+                                                                               <%=app.getPrintableProduktAvailability(product)%>
+                                                                       </td>
+                                                               </tr>
+                                                               <%
+                                                       }
+                                                       %>
+
+                                                       <tr>
+                                                               <td colspan="4" class="table_footer">
+                                                                       <input type="reset" value="Formular zurücksetzen" />
+                                                                       <input type="submit" name="edit" value="Ändern" />
+                                                                       <input type="submit" name="delete" value="Löschen" />
+                                                               </td>
+                                                       </tr>
+                                               </tbody>
+                                       </table>
+                                       </form>
+                               </div>
+
+                               <div class="para">
+                                       <form action="<%=request.getContextPath()%>/form_handler/admin/do_product.jsp" accept-charset="utf-8" id="add" method="post">
+                                       <div class="table">
+                                               <div class="table_header">
+                                                       Neues Produkt hinzufügen:
+                                               </div>
+
+                                               <fieldset id="product_data">
+                                                       <legend>Bitte alle Felder ausfüllen:</legend>
+
+                                                       <div class="data_row">
+                                                               <div class="table_left">
+                                                                       Produktbezeichnung:
+                                                                       <div class="tiny">(z.B. <em>Pizza Italia</em>)</div>
+                                                               </div>
+
+                                                               <div class="table_right">
+                                                                       <input type="text" name="title" size="10" maxlength="255" />
+                                                               </div>
+
+                                                               <div class="clear"></div>
+                                                       </div>
+
+                                                       <div class="data_row">
+                                                               <div class="table_left">
+                                                                       Einzelpreis:
+                                                                       <div class="tiny">(z.B. <em>50.0</em>)</div>
+                                                               </div>
+
+                                                               <div class="table_right">
+                                                                       <input type="text" name="price" size="10" maxlength="255" />
+                                                               </div>
+
+                                                               <div class="clear"></div>
+                                                       </div>
+                                               </fieldset>
+
+                                               <div class="table_footer">
+                                                       <input type="reset" value="Formular zurücksetzen" />
+                                                       <input type="submit" name="add" value="Hinzufügen" />
+                                               </div>
+                                       </div>
+                                       </form>
+                               </div>
+                               <div class="para">
+                                       Hinweise zum Hinzufügen von Produkten:
+                                       <ul>
+                                               <li>Beim Preis keine Währungszeichen (wie &euro; usw.) eingeben.</li>
+                                       </ul>
+                               </div>
+                       </div>
+               </div>
+       </body>
+</html>
diff --git a/web/admin/products.jsp b/web/admin/products.jsp
deleted file mode 100644 (file)
index 0999f8e..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-<%-- 
-       Document   : products
-       Created on : 04.08.2015, 10:55:10
-       Author     : Roland Haeder
---%>
-
-<%--<%@page errorPage="errorHandler.jsp" %>--%>
-<%@page import="java.util.Iterator"%>
-<%@page import="java.util.Map"%>
-<%@page import="org.mxchange.jcore.contact.Gender"%>
-<%@page import="org.mxchange.pizzaapplication.product.Product"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
-<%@page import="org.mxchange.pizzaapplication.beans.CustomerBean" %>
-<%@page contentType="text/html" pageEncoding="UTF-8"%>
-
-<jsp:useBean id="customer" scope="session" class="org.mxchange.pizzaapplication.customer.bean.PizzaServiceCustomerBean" type="CustomerBean" />
-<jsp:setProperty name="customer" property="*" />
-
-<%
-       // Init application instance
-       PizzaApplication app = PizzaServiceApplication.getInstance(application);
-%>
-<!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" xml:lang="de" lang="de">
-       <head>
-               <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-               <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Bestellung anzeigen</title>
-       </head>
-
-       <body>
-               <div id="title">
-                       <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Bestellung anzeigen</h1>
-               </div>
-
-               <jsp:include page="/static/admin/menu.jsp" flush="true" />
-
-               <div id="content_outer">
-                       <div id="content_title">
-                               <h2>Diese Produkte wurden eingestellt:</h2>
-                       </div>
-
-                       <div id="content">
-                               <div class="para">
-                                       <form action="<%=request.getContextPath()%>/form_handler/admin/do_products.jsp" accept-charset="utf-8" id="form" method="post">
-                                       <table class="table">
-                                               <thead class="table_header">
-                                                       <tr>
-                                                               <th class="table_header_column">
-                                                                       Produktname: (Schlüssel)
-                                                               </th>
-                                                               <th class="table_header_column">
-                                                                       Produktbezeichnung:
-                                                               </th>
-                                                               <th class="table_header_column">
-                                                                       Einzelpreis:
-                                                               </th>
-                                                               <th class="table_header_column">
-                                                                       Verfügbarkeit:
-                                                               </th>
-                                                       </tr>
-                                               </thead>
-
-                                               <tbody class="table_body">
-                                                       <%
-                                                       // "Walk" through all products and unmark them as ordered
-                                                       for (final Product product : app.getUnmarkedProducts(session)) {
-                                                               %>
-                                                               <tr>
-                                                                       <td>
-                                                                               <%=product.getName()%>
-                                                                       </td>
-                                                                       <td>
-                                                                               <%=product.getTitle()%>
-                                                                       </td>
-                                                                       <td>
-                                                                               <%=product.getPrice()%>
-                                                                       </td>
-                                                                       <td>
-                                                                               <%=app.getPrintableProduktAvailability(product)%>
-                                                                       </td>
-                                                               </tr>
-                                                               <%
-                                                       }
-                                                       %>
-
-                                                       <tr>
-                                                               <td colspan="3" class="table_footer">
-                                                                       <input type="reset" value="Formular zurücksetzen" />
-                                                                       <input type="submit" name="edit" value="Ändern" />
-                                                                       <input type="submit" name="delete" value="Löschen" />
-                                                               </td>
-                                                       </tr>
-                                               </tbody>
-                                       </table>
-                                       </form>
-                               </div>
-
-                               <div class="para">
-                                       <form action="<%=request.getContextPath()%>/form_handler/admin/do_products.jsp" accept-charset="utf-8" id="add" method="post">
-                                       <div class="table">
-                                               <div class="table_header">
-                                                       Neues Produkt hinzufügen:
-                                               </div>
-
-                                               <fieldset id="product_data">
-                                                       <legend>Bitte alle Felder ausfüllen:</legend>
-
-                                                       <div class="data_row">
-                                                               <div class="table_left">
-                                                                       Produktname:
-                                                                       <div class="tiny">(z.B. <em>italia</em>)</div>
-                                                               </div>
-
-                                                               <div class="table_right">
-                                                                       <input type="text" name="name" size="10" maxlength="255" />
-                                                               </div>
-
-                                                               <div class="clear"></div>
-                                                       </div>
-
-                                                       <div class="data_row">
-                                                               <div class="table_left">
-                                                                       Produktbezeichnung:
-                                                                       <div class="tiny">(z.B. <em>Pizza Italia</em>)</div>
-                                                               </div>
-
-                                                               <div class="table_right">
-                                                                       <input type="text" name="title" size="10" maxlength="255" />
-                                                               </div>
-
-                                                               <div class="clear"></div>
-                                                       </div>
-
-                                                       <div class="data_row">
-                                                               <div class="table_left">
-                                                                       Einzelpreis:
-                                                                       <div class="tiny">(z.B. <em>50.0</em>)</div>
-                                                               </div>
-
-                                                               <div class="table_right">
-                                                                       <input type="text" name="price" size="10" maxlength="255" />
-                                                               </div>
-
-                                                               <div class="clear"></div>
-                                                       </div>
-                                               </fieldset>
-
-                                               <div class="table_footer">
-                                                       <input type="reset" value="Formular zurücksetzen" />
-                                                       <input type="submit" name="add" value="Hinzufügen" />
-                                               </div>
-                                       </div>
-                                       </form>
-                               </div>
-                               <div class="para">
-                                       Hinweise zum Hinzufügen von Produkten:
-                                       <ul>
-                                               <li>Bitte bei Produktnamen immer klein schreieben, es wird aber klein konvertiert.</li>
-                                               <li>Bitte dabei nur Zeichen von <em>a</em> bis <em>z</em> verwenden.</li>
-                                               <li>Der Produktname darf nur maximal einmal vorkommen!</li>
-                                               <li>Beim Preis keine Währungszeichen (wie &euro; usw.) eingeben.</li>
-                                       </ul>
-                               </div>
-                       </div>
-               </div>
-       </body>
-</html>
index d6129ad3f77bfeb34d330847b87f8a7903c89433..05afdbfb1d0bb42c9014a18ff32aa53eeb3223c7 100644 (file)
                                        <tbody class="table_body">
                                                <%
                                                // "Walk" through all products and unmark them as ordered
-                                               for (final Product product : app.getUnmarkedProducts(session)) {
+                                               for (final Product product : app.getProducts()) {
+                                                       // Unmark as ordered
+                                                       app.unmarkProductAsOrdered(product, session);
                                                        %>
                                                        <tr>
                                                                <td>
-                                                                       <input type="checkbox" name="<%=String.format(PizzaApplication.HTTP_PARAM_MASK, PizzaApplication.HTTP_PARAM_CHOOSE, product.getName())%>" value="1" <%=app.getCheckedHtmlFromProduct(product, request, session)%> />
+                                                                       <input type="checkbox" name="<%=String.format(PizzaApplication.HTTP_PARAM_MASK, PizzaApplication.HTTP_PARAM_CHOOSE, product.getId())%>" value="1" <%=app.getCheckedHtmlFromProduct(product, request, session)%> />
                                                                </td>
                                                                <td>
-                                                                       <input type="text" name="<%=String.format(PizzaApplication.HTTP_PARAM_MASK, PizzaApplication.HTTP_PARAM_AMOUNT, product.getName())%>" value="<%=app.getAmountFromSession(product, session)%>" size="3" maxlength="20" />
+                                                                       <input type="text" name="<%=String.format(PizzaApplication.HTTP_PARAM_MASK, PizzaApplication.HTTP_PARAM_AMOUNT, product.getId())%>" value="<%=app.getAmountFromSession(product, session)%>" size="3" maxlength="20" />
                                                                </td>
                                                                <td>
                                                                        <%=product.getTitle()%>
index 13233c493948efe76970b5952a3b55f536ae93cb..dd3007826bc0713103e5d6f8f89351ec80c43f8f 100644 (file)
@@ -66,7 +66,9 @@
                                        <tbody class="table_body">
                                                <%
                                                // "Walk" through all products and unmark them as ordered
-                                               for (final Product product : app.getUnmarkedProducts(session)) {
+                                               for (final Product product : app.getProducts()) {
+                                                       // Unmark it as ordered
+                                                       app.unmarkProductAsOrdered(product, session);
                                                        %>
                                                        <tr>
                                                                <td>
index 8b33115359657eaa0a7c092866a89eedc7274d75..627ffde63c5c781df29e4bee098fed1ca7f585f9 100644 (file)
@@ -7,7 +7,8 @@
 <div id="menu">
        <ul>
                <li><a href="<%=request.getContextPath()%>/admin/index.jsp" title="Eingangsseite">Home</a></li>
-               <li><a href="<%=request.getContextPath()%>/admin/products.jsp" title="Produkte">Produkte</a></li>
+               <li><a href="<%=request.getContextPath()%>/admin/category.jsp" title="Kazegorie">Kategorie</a></li>
+               <li><a href="<%=request.getContextPath()%>/admin/product.jsp" title="Produkt">Produkt</a></li>
        </ul>
 
        <ul>