]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Moved some classes + other stuff
authorRoland Haeder <roland@mxchange.org>
Thu, 6 Aug 2015 12:17:27 +0000 (14:17 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 6 Aug 2015 12:17:27 +0000 (14:17 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

17 files changed:
src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/customer/Customer.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/customer/PizzaServiceCustomer.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/customer/bean/CustomerBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/product/PizzaProduct.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/product/Product.java [new file with mode: 0644]
src/java/org/mxchange/pizzaservice/application/PizzaApplication.java [deleted file]
src/java/org/mxchange/pizzaservice/application/PizzaServiceApplication.java [deleted file]
src/java/org/mxchange/pizzaservice/product/PizzaProduct.java [deleted file]
src/java/org/mxchange/pizzaservice/product/Product.java [deleted file]
web/bye.jsp
web/errorHandler.jsp
web/finished.jsp
web/index.jsp
web/order.jsp
web/style.css [new file with mode: 0644]

diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java
new file mode 100644 (file)
index 0000000..a01c56d
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+ * 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.application;
+
+import java.util.Iterator;
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import org.mxchange.jcore.application.Application;
+import org.mxchange.pizzaapplication.product.Product;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public interface PizzaApplication extends Application {
+       /**
+        * HTTP parameter "amount"
+        */
+       public static final String HTTP_PARAM_AMOUNT = "amount";
+
+       /**
+        * HTTP parameter "choose"
+        */
+       public static final String HTTP_PARAM_CHOOSE = "choose";
+
+       /**
+        * Session key "ordered"
+        */
+       public static final String SESSION_ORDERED = "ordered";
+
+       /**
+        * Mask for all parameters
+        */
+       public static final String HTTP_PARAM_MASK = "%s[%s]";
+
+       /**
+        * Getter for product iterator
+        * 
+        * @return Iterator for all products
+        */
+       public Iterator<Map.Entry<String, Product>> getProductsIterator ();
+
+       /**
+        * Some "getter" for amount from session
+        *
+        * @param product Product instance
+        * @param session Session instance
+        * @return Amount as string
+        */
+       public String getAmountFromSession (final Product product, final HttpSession session);
+
+       /**
+        * Some "getter" for choose from session
+        *
+        * @param product Product instance
+        * @param session Session instance
+        * @return Choose as string
+        */
+       public String getChooseFromSession (final Product product, final HttpSession session);
+
+       /**
+        * Handler for amount from session
+        *
+        * @param product Product instance
+        * @param request Request instance
+        * @param session Session instance
+        * @return Amount as string
+        */
+       public String handleAmountFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
+
+       /**
+        * Handler for choosen (checkbox) from request or session
+        *
+        * @param product Product instance
+        * @param request Request instance
+        * @param session Session instance
+        * @return Amount as string
+        */
+       public String handleChooseFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
+
+       /**
+        * Some "getter" for printable choosen (checkbox) from request or session
+        *
+        * @param product Product instance
+        * @param request Request instance
+        * @param session Session instance
+        * @return Amount as string
+        */
+       public String getPrintableChoosenFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
+
+       /**
+        * Some "getter" for total price of position from request or session.
+        * Single price and amount is multiplyed.
+        *
+        * @param product Product instance
+        * @param request Request instance
+        * @param session Session instance
+        * @return Amount as string
+        */
+       public float getTotalPositionPriceFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
+
+       /**
+        * Checks whether the given product is choosen, request overules session.
+        *
+        * @param product Product instance
+        * @param request Request instance
+        * @param session Session instance
+        * @return Whether the product is choosen
+        */
+       public boolean isProductChoosen (final Product product, final HttpServletRequest request, final HttpSession session);
+
+       /**
+        * Calculates total price of all choosen products
+        *
+        * @param request Request instance
+        * @param session Session instance
+        * @return Total price of all choosen products
+        */
+       public float calculateTotalPrice (final HttpServletRequest request, final HttpSession session);
+
+       /**
+        * Calculates total amount of all choosen products
+        *
+        * @param request Request instance
+        * @param session Session instance
+        * @return Total amount of all choosen products
+        */
+       public int calculateTotalAmount (final HttpServletRequest request, final HttpSession session);
+
+       /**
+        * Some "getter" for HTML code 'checked="checked"' if the product is choosen
+        *
+        * @param product Product instance
+        * @param request Request instance
+        * @param session Session instance
+        * @return Whether the product is choosen
+        */
+       public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session);
+
+       /**
+        * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
+        *
+        * @param request Request instance
+        * @param session Session instance
+        * @return Whether the product is choosen
+        */
+       public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session);
+
+       /**
+        * Marks given product as ordered in session
+        *
+        * @param product Product to mark as ordered
+        * @param session Session instance
+        */
+       public void markProductAsOrdered(final Product product, final HttpSession session);
+
+       /**
+        * Unmarks given product as ordered in session
+        *
+        * @param product Product to unmark as ordered
+        * @param session Session instance
+        */
+       public void unmarkProductAsOrdered(final Product product, final HttpSession session);
+}
diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java
new file mode 100644 (file)
index 0000000..8a6e4bf
--- /dev/null
@@ -0,0 +1,936 @@
+/*
+ * 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.application;
+
+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;
+import javax.servlet.http.HttpSession;
+import org.mxchange.jcore.BaseFrameworkSystem;
+import org.mxchange.pizzaapplication.product.PizzaProduct;
+import org.mxchange.pizzaapplication.product.Product;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public class PizzaServiceApplication extends BaseFrameworkSystem implements PizzaApplication {
+       /**
+        * Main title
+        */
+       public static final String MAIN_TITLE = "Pizza-Service";
+
+       /**
+        * Product list
+        */
+       private final SortedMap<String, Product> products;
+
+       /**
+        * Some singleton getter for this instance. If the instance is not set in
+        * given application, it will be created.
+        *
+        * @param application Servlet context
+        * @return This instance
+        * @throws javax.servlet.ServletException If object is not set correctly
+        */
+       public static final PizzaApplication getInstance (final ServletContext application) throws ServletException {
+               // Trace message
+               new PizzaServiceApplication().getLogger().trace(MessageFormat.format("application={0} - CALLED!", application)); //NOI18N
+
+               if (application == null) {
+                       // Not set
+                       throw new NullPointerException("application is null"); //NOI18N
+               }
+
+                       // Init instance
+               PizzaServiceApplication instance = null;
+
+               // Get instance from servlet
+               Object object = application.getAttribute("service"); //NOI18N
+
+               // Is it set?
+               if (object instanceof PizzaServiceApplication) {
+                       // Instance is set, so casting should work
+                       instance = (PizzaServiceApplication) object;
+               } else if (object instanceof Object) {
+                       // Not correct instance
+                       throw new ServletException("service is not set correctly"); //NOI18N
+               } else {
+                       // "service" is null, so initialize it
+                       instance = new PizzaServiceApplication();
+
+                       // And set it here
+                       application.setAttribute("service", instance); //NOI18N
+               }
+
+               // Trace message
+               instance.getLogger().trace(MessageFormat.format("instance={0} - EXIT!", instance)); //NOI18N
+
+               // Return it
+               return instance;
+       }
+
+       /**
+        * Private constructor
+        */
+       private PizzaServiceApplication () {
+               // Init products instance
+               this.products = new TreeMap<>();
+
+               // Fill products list
+               this.fillProductsList();
+       }
+
+       @Override
+       public void doBootstrap () {
+               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       }
+
+       @Override
+       public void doMainLoop () {
+               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       }
+
+       @Override
+       public void doShutdown () {
+               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       }
+
+       /**
+        * Getter for product (list) iterator
+        *
+        * @return An interator on all listed products
+        */
+       @Override
+       public Iterator<Map.Entry<String, Product>> getProductsIterator () {
+               assert(this.products instanceof SortedMap) : "this.products is not initialized"; //NOI18N
+               return this.products.entrySet().iterator();
+       }
+
+       /**
+        * Adds given product to list or throws an exception if name is already found
+        *
+        * @param name Internal name of product
+        * @param title Product's title
+        * @param price Price
+        */
+       private void addProduct (final String name, final String title, final float price) {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("name={0},title={1},price={2} - CALLED!", name, title, price)); //NOI18N
+
+               // Is the name already used?
+               if (this.isProductNameUsed(name)) {
+                       // Something went wrong
+                       throw new IllegalArgumentException(MessageFormat.format("product {0} is already used.", name)); //NOI18N
+               }
+
+               // Instance product
+               Product product = new PizzaProduct(name, title, price);
+
+               // 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
+        * 
+        * @param product Product instance
+        * @param session Session instance
+        * @param parameter Parameter to clear
+        */
+       private void clearSessionAttribute (final Product product, final HttpSession session, final String parameter) {
+               // Trace message
+               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.setValueInSession(product, session, parameter, null);
+
+               // Trace message
+               this.getLogger().trace("EXIT!"); //NOI18N
+       }
+
+       /**
+        * Fills products list
+        * @todo Very hard-coded stuff ...
+        */
+       private void fillProductsList () {
+               // Trace message
+               this.getLogger().trace("CALLED!"); //NOI18N
+
+               // Add products
+               this.addProduct("italia", "Pizza Italia", 5.50f); //NOI18N
+               this.addProduct("diablo", "Pizza Diablo", 7.80f); //NOI18N
+               this.addProduct("bolognese", "Spagetti Bolognese", 11.95f); //NOI18N
+
+               // Trace message
+               this.getLogger().trace("EXIT!"); //NOI18N
+       }
+
+       /**
+        * Some getter for value from session
+        *
+        * @param product Product instance
+        * @param session Session instance
+        * @param attribute Attribute to get value from
+        * @return Value from session
+        */
+       private Object getValueFromSession (final Product product, final HttpSession session, final String attribute) {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("product={0},session={1},attribute={2} - CALLED!", product, session, attribute)); //NOI18N
+
+               // Init variable
+               Object value = null;
+
+               // Get it synced
+               synchronized (session) {
+                       value = session.getAttribute(String.format(HTTP_PARAM_MASK, product.getName(), attribute));
+               }
+
+               this.getLogger().debug(MessageFormat.format("product={0},attribute={1},value={2}", product.getName(), attribute, value)); //NOI18N
+
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("value={0} - EXIT!", value)); //NOI18N
+
+               // Return it
+               return value;
+       }
+
+       /**
+        * Checks whether given product is already used
+        *
+        * @param name Name of product
+        * @return Whether the given product's name is already used
+        */
+       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);
+       }
+
+       /**
+        * For debugging purpose
+        *
+        * @param args Arguments
+        */
+       public static void main (String[] args) {
+               // Get instance and start it
+               new PizzaServiceApplication().start();
+       }
+
+       /**
+        * Checks if the product ordered?
+        *
+        * @param product 
+        * @param session
+        * @return 
+        */
+       private boolean isProductOrdered (final Product product, final HttpSession session) {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("product={0},session={1} - CALLED!", product, session)); //NOI18N
+
+               // Get session
+               Object isOrdered = this.getValueFromSession(product, session, SESSION_ORDERED);
+               this.getLogger().debug(MessageFormat.format("product={0},isOrdered={1}", product.getName(), isOrdered)); //NOI18N
+
+               // Return result
+               return ("true".equals(isOrdered)); //NOI18N
+       }
+
+       /**
+        * Somewhat setter in session
+        *
+        * @param product Product instance
+        * @param session Session instance
+        * @param keyPart Key part to include in final key
+        * @param value Value to set
+        */
+       private void setValueInSession (final Product product, final HttpSession session, final String keyPart, final Object value) {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("product={0},session={1},keyPart={2},value={3} - CALLED!", product, session, keyPart, value)); //NOI18N
+
+               synchronized(session) {
+                       // Set it synced
+                       this.getLogger().debug(MessageFormat.format("setValueInSession: Setting value={0} for product={1},keyPart={2}", value, product.getName(), keyPart)); //NOI18N
+                       session.setAttribute(String.format(HTTP_PARAM_MASK, product.getName(), keyPart), value);
+               }
+
+               // Trace message
+               this.getLogger().trace("EXIT!"); //NOI18N
+       }
+
+       /**
+        * Application starter
+        */
+       private void start () {
+               // Get iterator
+               Iterator<Map.Entry<String, Product>> iterator = this.getProductsIterator();
+
+               // Run over it
+               while (iterator.hasNext()) {
+                       // Get product instance
+                       Map.Entry<String, Product> entry = iterator.next();
+
+                       // Get value
+                       Product product = entry.getValue();
+
+                       // Output data
+                       this.getLogger().debug(MessageFormat.format("Product {0}, {1}: {2}", product.getName(), product.getTitle(), product.getPrice())); //NOI18N
+               }
+       }
+
+       /**
+        * Some "getter" for amount from session
+        * @param product Product instance
+        * @param session Session instance
+        * @return Amount as string
+        */
+       @Override
+       public String getAmountFromSession (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
+               }
+
+               // Get attribute
+               Object object = this.getValueFromSession(product, session, HTTP_PARAM_AMOUNT);
+
+               // Is the object null?
+               if (object == null) {
+                       // Trace message
+                       this.getLogger().trace("Returning 0 - EXIT!"); //NOI18N
+
+                       // Not found
+                       return "0"; //NOI18N
+               }
+
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("object={0} - EXIT!", object)); //NOI18N
+
+               // Cast to string and return it
+               return (String) object;
+       }
+
+       /**
+        * Some "getter" for choose from session
+        * 
+        * @param product Product instance
+        * @param session Session instance
+        * @return Choose as string
+        */
+       @Override
+       public String getChooseFromSession (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
+               }
+
+               // Get attribute
+               Object object = this.getValueFromSession(product, session, HTTP_PARAM_CHOOSE);
+
+               // Is the object null?
+               if (object == null) {
+                       // Not found
+                       this.getLogger().debug(MessageFormat.format("Returning empty string for product={0} ...", product.getName())); //NOI18N
+                       return ""; //NOI18N
+               }
+
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("object={0} - CALLED!", object)); //NOI18N
+
+               // Cast to string and return it
+               return (String) object;
+       }
+
+       /**
+        * Handler for amount from request or session
+        * 
+        * @param product Product instance
+        * @param request Request instance
+        * @param session Session instance
+        * @return Amount as string
+        */
+       @Override
+       public String handleAmountFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session) {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
+
+               // Is product and session set?
+               if (product == null) {
+                       // Not set
+                       throw new NullPointerException("product is null"); //NOI18N
+               } else if (request == null) {
+                       // Not set
+                       throw new NullPointerException("request is null"); //NOI18N
+               } else if (session == null) {
+                       // Not set
+                       throw new NullPointerException("session is null"); //NOI18N
+               }
+
+               // Init variabke
+               Object object;
+
+               // Check request method
+               if (!"POST".equals(request.getMethod())) { //NOI18N
+                       // Not POST, so get from session
+                       return this.getAmountFromSession(product, session);
+               } 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
+                       return "0"; //NOI18N
+               }
+
+               // Get attribute from request
+               object = request.getParameter(String.format(HTTP_PARAM_MASK, HTTP_PARAM_AMOUNT, product.getName()));
+
+               // Is it set?
+               if (object instanceof String) {
+                       // Try to parse it to integer
+                       try {
+                               Integer value = Integer.valueOf((String) object);
+                       } catch (final NumberFormatException ex) {
+                               // Not valid input
+                               this.getLogger().warn(ex);
+                               return "0"; //NOI18N
+                       }
+
+                       // Then set it in session
+                       this.setValueInSession(product, session, HTTP_PARAM_AMOUNT, object);
+
+                       // And return it
+                       return (String) object;
+               }
+
+               // Trace message
+               this.getLogger().trace("Calling getAmountFromSession() ..."); //NOI18N
+
+               // Get attribute from session
+               return this.getAmountFromSession(product, session);
+       }
+
+       /**
+        * Handler for choosen (checkbox) from request or session
+        *
+        * @param product Product instance
+        * @param request Request instance
+        * @param session Session instance
+        * @return Amount as string
+        */
+       @Override
+       public String handleChooseFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session) {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
+
+               // Is product and session set?
+               if (product == null) {
+                       // Not set
+                       throw new NullPointerException("product is null"); //NOI18N
+               } else if (request == null) {
+                       // Not set
+                       throw new NullPointerException("request is null"); //NOI18N
+               } else if (session == null) {
+                       // Not set
+                       throw new NullPointerException("session is null"); //NOI18N
+               }
+
+               // Init variabke
+               Object object;
+
+               // Check request method
+               if (!"POST".equals(request.getMethod())) { //NOI18N
+                       // Not POST, so get from session
+                       return this.getChooseFromSession(product, session);
+               } else if (this.isProductOrdered(product, session)) {
+                       // Product is ordered
+                       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
+
+               // Is it null?
+               if (object == null) {
+                       // Unset session
+                       this.getLogger().debug(MessageFormat.format("Unsetting session for product={0} ...", product.getName())); //NOI18N
+                       this.clearSessionAttribute(product, session, HTTP_PARAM_CHOOSE);
+                       this.clearSessionAttribute(product, session, HTTP_PARAM_AMOUNT);
+
+                       // Return empty string
+                       return ""; //NOI18N
+               }
+
+               // Then set it in session
+               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
+               return (String) object;
+       }
+
+       /**
+        * Some "getter" for choosen (checkbox) from session
+        *
+        * @param product Product instance
+        * @param request Request instance
+        * @param session Session instance
+        * @return Amount as string
+        */
+       @Override
+       public String getPrintableChoosenFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session) {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
+
+               // Is product and session set?
+               if (product == null) {
+                       // Not set
+                       throw new NullPointerException("product is null"); //NOI18N
+               } else if (request == null) {
+                       // Not set
+                       throw new NullPointerException("request is null"); //NOI18N
+               } else if (session == null) {
+                       // Not set
+                       throw new NullPointerException("session is null"); //NOI18N
+               }
+
+               // Get element
+               String choosen = this.handleChooseFromRequestSession(product, request, session);
+               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getName(), choosen)); //NOI18N
+
+               // Must not be null
+               assert(choosen instanceof String): "choosen is null"; //NOI18N
+
+               // Is it empty?
+               if (choosen.isEmpty()) {
+                       // Not choosen
+                       return "Nein";
+               }
+
+               // Get amount
+               String amount = this.handleAmountFromRequestSession(product, request, session);
+               this.getLogger().debug(MessageFormat.format("product={0},amount={1}", product.getName(), amount)); //NOI18N
+
+               // Must not be null
+               assert(amount instanceof String): "amount is null"; //NOI18N
+
+               // Is it empty?
+               if (amount.isEmpty() || "0".equals(amount)) { //NOI18N
+                       // Choosen, but no amount
+                       return "Nein";
+               } else {
+                       // Is choosen
+                       return "Ja";
+               }
+       }
+
+       /**
+        * Some "getter" for total price of position from request or session.
+        * Single price and amount is multiplyed.
+        *
+        * @param product Product instance
+        * @param request Request instance
+        * @param session Session instance
+        * @return Amount as string
+        */
+       @Override
+       public float getTotalPositionPriceFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session) {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
+
+               // Is product and session set?
+               if (product == null) {
+                       // Not set
+                       throw new NullPointerException("product is null"); //NOI18N
+               } else if (request == null) {
+                       // Not set
+                       throw new NullPointerException("request is null"); //NOI18N
+               } else if (session == null) {
+                       // Not set
+                       throw new NullPointerException("session is null"); //NOI18N
+               }
+
+               // Get choosen
+               String choosen = this.handleChooseFromRequestSession(product, request, session);
+               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getName(), choosen)); //NOI18N
+
+               // Must not be null
+               assert(choosen instanceof String): "choosen is null"; //NOI18N
+
+               // Is it set?
+               if (choosen.isEmpty()) {
+                       // Is empty
+                       this.getLogger().debug(MessageFormat.format("product={0},choosen={1} - returning zero ...", product.getName(), 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
+
+               // Must not be null
+               assert(amount instanceof String): "amount is null"; //NOI18N
+
+               // 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
+                       return 0.00f;
+               }
+
+               // Init variable
+               Integer value = null;
+
+               // Try it
+               try {
+                       // Get amount as integer
+                       value = Integer.valueOf(amount);
+               } catch (final NumberFormatException e) {
+                       // Bat input
+                       throw new IllegalArgumentException(e);
+               }
+
+               // Calculate price
+               float price = (product.getPrice() * value);
+
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("product={0},price={1} - EXIT!", product.getName(), price)); //NOI18N
+
+               // Then multiply it with price
+               return price;
+       }
+
+       /**
+        * Checks whether the given product is choosen, request overules session.
+        *
+        * @param product Product instance
+        * @param request Request instance
+        * @param session Session instance
+        * @return Whether the product is choosen
+        */
+       @Override
+       public boolean isProductChoosen (final Product product, final HttpServletRequest request, final HttpSession session) {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
+
+               // Is product and session set?
+               if (product == null) {
+                       // Not set
+                       throw new NullPointerException("product is null"); //NOI18N
+               } else if (request == null) {
+                       // Not set
+                       throw new NullPointerException("request is null"); //NOI18N
+               } else if (session == null) {
+                       // Not set
+                       throw new NullPointerException("session is null"); //NOI18N
+               }
+
+               // Get choosen
+               String choosen = this.handleChooseFromRequestSession(product, request, session);
+               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getName(), choosen)); //NOI18N
+
+               // Must not be null
+               assert(choosen instanceof String): "choosen is null"; //NOI18N
+
+               // Is it not choosen?
+               if (choosen.isEmpty()) {
+                       // Not choosen
+                       return false;
+               }
+
+               // Get amount
+               String amount = this.handleAmountFromRequestSession(product, request, session);
+
+               // Must not be null
+               assert(amount instanceof String): "amount is not set"; //NOI18N
+
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("amount={0} - EXIT!", amount)); //NOI18N
+
+               // Must not be empty and not 0
+               return (!amount.isEmpty() && !"0".equals(amount)); //NOI18N
+       }
+
+       /**
+        * Calculates total price of all choosen products
+        *
+        * @param request Request instance
+        * @param session Session instance
+        * @return Total price of all choosen products
+        */
+       @Override
+       public float calculateTotalPrice (final HttpServletRequest request, final HttpSession session) {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("request={0},session={1} - CALLED!", request, session)); //NOI18N
+
+               // Is product and session set?
+               if (request == null) {
+                       // Not set
+                       throw new NullPointerException("request is null"); //NOI18N
+               } else if (session == null) {
+                       // Not set
+                       throw new NullPointerException("session is null"); //NOI18N
+               }
+
+               // Init total price
+               float totalPrice = 0.00f;
+
+               // Get iterator
+               Iterator<Map.Entry<String, Product>> iterator = this.getProductsIterator();
+
+               // Walk through all products
+               while (iterator.hasNext()) {
+                       // Get entry
+                       Map.Entry<String, Product> entry = iterator.next();
+
+                       // Get product instance
+                       Product product = entry.getValue();
+
+                       // Is this choosen?
+                       if (product.isChoosen()) {
+                               // Then add product's total price
+                               this.getLogger().debug(MessageFormat.format("Calling getTotalPositionPriceFromRequestSession({0},request,session) ...", product.getName())); //NOI18N
+                               totalPrice += this.getTotalPositionPriceFromRequestSession(product, request, session);
+                       }
+                       this.getLogger().debug(MessageFormat.format("product={0},totalPrice={1}", product.getName(), totalPrice)); //NOI18N
+               }
+
+               // Trace message
+               this.getLogger().trace(MessageFormat.format(" totalPrice={0} - EXIT!", totalPrice)); //NOI18N
+
+               // Return total price
+               return totalPrice;
+       }
+
+       /**
+        * Calculates total amount of all choosen products
+        *
+        * @param request Request instance
+        * @param session Session instance
+        * @return Total amount of all choosen products
+        */
+       @Override
+       public int calculateTotalAmount (final HttpServletRequest request, final HttpSession session) {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("request={0},session={1} - CALLED!", request, session)); //NOI18N
+
+               // Is product and session set?
+               if (request == null) {
+                       // Not set
+                       throw new NullPointerException("request is null"); //NOI18N
+               } else if (session == null) {
+                       // Not set
+                       throw new NullPointerException("session is null"); //NOI18N
+               }
+
+               // Init total price
+               int totalAmount = 0;
+
+               // Get iterator
+               Iterator<Map.Entry<String, Product>> iterator = this.getProductsIterator();
+
+               // Walk through all products
+               while (iterator.hasNext()) {
+                       // Get entry
+                       Map.Entry<String, Product> entry = iterator.next();
+
+                       // Get product instance
+                       Product product = entry.getValue();
+
+                       // Is this choosen?
+                       if (product.isChoosen()) {
+                               // Then add ordered amount
+                               this.getLogger().debug(MessageFormat.format("Counting {0} ...", product.getName())); //NOI18N
+
+                               // Getting amount
+                               String amount = this.getAmountFromSession(product, session);
+
+                               // Add it up
+                               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
+               }
+
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("totalAmount={0} - EXIT!", totalAmount)); //NOI18N
+
+               // Return total price
+               return totalAmount;
+       }
+
+       /**
+        * Some "getter" for HTML code 'checked="checked"' if the product is choosen
+        *
+        * @param product Product instance
+        * @param request Request instance
+        * @param session Session instance
+        * @return Whether the product is choosen
+        */
+       @Override
+       public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session) {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
+
+               // Is product and session set?
+               if (product == null) {
+                       // Not set
+                       throw new NullPointerException("product is null"); //NOI18N
+               } else if (request == null) {
+                       // Not set
+                       throw new NullPointerException("request is null"); //NOI18N
+               } else if (session == null) {
+                       // Not set
+                       throw new NullPointerException("session is null"); //NOI18N
+               }
+
+               // First let's check if the product is choosen
+               if (this.isProductChoosen(product, request, session)) {
+                       // Trace message
+                       this.getLogger().trace("Returning checked=\"checked\" - EXIT!"); //NOI18N
+
+                       // Is choosen
+                       return "checked=\"checked\""; //NOI18N
+               } else {
+                       // Trace message
+                       this.getLogger().trace("Returning empty string - EXIT!"); //NOI18N
+
+                       // Not choosen
+                       return ""; //NOI18N
+               }
+       }
+
+       /**
+        * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
+        *
+        * @param request Request instance
+        * @param session Session instance
+        * @return Whether the product is choosen
+        */
+       @Override
+       public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session) {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("request={0},session={1} - CALLED!", request, session)); //NOI18N
+
+               // Is product and session set?
+               if (request == null) {
+                       // Not set
+                       throw new NullPointerException("request is null"); //NOI18N
+               } else if (session == null) {
+                       // Not set
+                       throw new NullPointerException("session is null"); //NOI18N
+               }
+
+               // Is something selected?
+               if (this.calculateTotalAmount(request, session) > 0) {
+                       // Trace message
+                       this.getLogger().trace("Returning empty string - EXIT!"); //NOI18N
+
+                       // Something has been choosen
+                       return ""; //NOI18N
+               } else {
+                       // Trace message
+                       this.getLogger().trace("Returning disabled=\"disabled\" - EXIT!"); //NOI18N
+
+                       // Nothing choosen yet
+                       return "disabled=\"disabled\""; //NOI18N
+               }
+       }
+
+       /**
+        * Marks given product as ordered in session
+        *
+        * @param product Product to mark as ordered
+        * @param session Session instance
+        */
+       @Override
+       public void markProductAsOrdered(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 ordered.", product.getName())); //NOI18N
+               this.setValueInSession(product, session, SESSION_ORDERED, "true"); //NOI18N
+
+               // Trace message
+               this.getLogger().trace("EXIT!"); //NOI18N
+       }
+
+       /**
+        * Unmarks given product as ordered in session
+        *
+        * @param product Product to unmark as ordered
+        * @param session Session instance
+        */
+       @Override
+       public void unmarkProductAsOrdered(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("Unmarking product={0} as ordered.", product.getName())); //NOI18N
+               this.clearSessionAttribute(product, session, SESSION_ORDERED);
+
+               // Trace message
+               this.getLogger().trace("EXIT!"); //NOI18N
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/customer/Customer.java b/src/java/org/mxchange/pizzaapplication/customer/Customer.java
new file mode 100644 (file)
index 0000000..8dd1148
--- /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.customer;
+
+import org.mxchange.jcore.contact.Contact;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public interface Customer extends Contact {
+       
+}
diff --git a/src/java/org/mxchange/pizzaapplication/customer/PizzaServiceCustomer.java b/src/java/org/mxchange/pizzaapplication/customer/PizzaServiceCustomer.java
new file mode 100644 (file)
index 0000000..a83f065
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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.customer;
+
+import org.mxchange.jcore.contact.BaseContact;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public class PizzaServiceCustomer extends BaseContact implements Customer {
+}
diff --git a/src/java/org/mxchange/pizzaapplication/customer/bean/CustomerBean.java b/src/java/org/mxchange/pizzaapplication/customer/bean/CustomerBean.java
new file mode 100644 (file)
index 0000000..459f5bc
--- /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.customer.bean;
+
+import org.mxchange.pizzaapplication.customer.PizzaServiceCustomer;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public class CustomerBean extends PizzaServiceCustomer {
+       
+}
diff --git a/src/java/org/mxchange/pizzaapplication/product/PizzaProduct.java b/src/java/org/mxchange/pizzaapplication/product/PizzaProduct.java
new file mode 100644 (file)
index 0000000..ba32ecb
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * 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.product;
+
+import java.text.MessageFormat;
+import org.mxchange.jcore.BaseFrameworkSystem;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public class PizzaProduct extends BaseFrameworkSystem implements Product {
+       /**
+        * Whether this product is choosen (default: false)
+        */
+       private boolean choosen = false;
+
+       /**
+        * Name of product
+        */
+       private String name;
+
+       /**
+        * Price of product
+        */
+       private float price;
+
+       /**
+        * Title of product
+        */
+       private String title;
+
+       /**
+        * Constructor for products with a name and a price.
+        * 
+        * @param name Name of product
+        * @param title Name of product
+        * @param price Price
+        */
+       public PizzaProduct (final String name, final String title, final float price) {
+               this.setName(name);
+               this.setTitle(title);
+               this.setPrice(price);
+       }
+
+       /**
+        * Name of product
+        * @return the name
+        */
+       @Override
+       public final String getName () {
+               return this.name;
+       }
+
+       /**
+        * Name of product
+        * @param name the name to set
+        */
+       protected final void setName (final String name) {
+               this.name = name;
+       }
+
+       /**
+        * Price of product
+        * @return the price
+        */
+       @Override
+       public final float getPrice () {
+               return this.price;
+       }
+
+       /**
+        * Price of product
+        * @param price the price to set
+        */
+       protected final void setPrice (final float price) {
+               this.price = price;
+       }
+
+       /**
+        * Title of product
+        * @return the title
+        */
+       @Override
+       public final String getTitle () {
+               return this.title;
+       }
+
+       /**
+        * Title of product
+        * @param title the title to set
+        */
+       protected final void setTitle (final String title) {
+               this.title = title;
+       }
+
+       /**
+        * Whether this product is choosen (default: false)
+        *
+        * @return the choosen
+        */
+       @Override
+       public final boolean isChoosen () {
+               return this.choosen;
+       }
+
+       /**
+        * Whether this product is choosen (default: false)
+        * @param choosen the choosen to set
+        */
+       protected final void setChoosen (boolean choosen) {
+               this.choosen = choosen;
+       }
+
+       /**
+        * Marks product as choosen
+        */
+       @Override
+       public void markAsChoosen () {
+               // Set it
+               this.getLogger().debug(MessageFormat.format("product={0} marked as choosen.", this.getName()));
+               this.setChoosen(true);
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/product/Product.java b/src/java/org/mxchange/pizzaapplication/product/Product.java
new file mode 100644 (file)
index 0000000..dfe5a70
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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.product;
+
+import org.mxchange.jcore.FrameworkInterface;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public interface Product extends FrameworkInterface {
+       /**
+        * Getter for name, suitable for form fields.
+        * 
+        * @return Name of product
+        */
+       public String getName ();
+
+       /**
+        * Getter for title.
+        * 
+        * @return Title of product
+        */
+       public String getTitle ();
+
+       /**
+        * Getter for raw price.
+        * 
+        * @return Single price of product
+        */
+       public float getPrice ();
+
+       /**
+        * Whether this product is choosen (default: false)
+        *
+        * @return the choosen
+        */
+       public boolean isChoosen ();
+
+       /**
+        * Marks product as choosen
+        */
+       public void markAsChoosen ();
+}
diff --git a/src/java/org/mxchange/pizzaservice/application/PizzaApplication.java b/src/java/org/mxchange/pizzaservice/application/PizzaApplication.java
deleted file mode 100644 (file)
index d386798..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * 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.pizzaservice.application;
-
-import java.util.Iterator;
-import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import org.mxchange.jcore.application.Application;
-import org.mxchange.pizzaservice.product.Product;
-
-/**
- *
- * @author Roland Haeder
- */
-public interface PizzaApplication extends Application {
-       /**
-        * HTTP parameter "amount"
-        */
-       public static final String HTTP_PARAM_AMOUNT = "amount";
-
-       /**
-        * HTTP parameter "choose"
-        */
-       public static final String HTTP_PARAM_CHOOSE = "choose";
-
-       /**
-        * Session key "ordered"
-        */
-       public static final String SESSION_ORDERED = "ordered";
-
-       /**
-        * Mask for all parameters
-        */
-       public static final String HTTP_PARAM_MASK = "%s[%s]";
-
-       /**
-        * Getter for product iterator
-        * 
-        * @return Iterator for all products
-        */
-       public Iterator<Map.Entry<String, Product>> getProductsIterator ();
-
-       /**
-        * Some "getter" for amount from session
-        *
-        * @param product Product instance
-        * @param session Session instance
-        * @return Amount as string
-        */
-       public String getAmountFromSession (final Product product, final HttpSession session);
-
-       /**
-        * Some "getter" for choose from session
-        *
-        * @param product Product instance
-        * @param session Session instance
-        * @return Choose as string
-        */
-       public String getChooseFromSession (final Product product, final HttpSession session);
-
-       /**
-        * Handler for amount from session
-        *
-        * @param product Product instance
-        * @param request Request instance
-        * @param session Session instance
-        * @return Amount as string
-        */
-       public String handleAmountFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
-
-       /**
-        * Handler for choosen (checkbox) from request or session
-        *
-        * @param product Product instance
-        * @param request Request instance
-        * @param session Session instance
-        * @return Amount as string
-        */
-       public String handleChooseFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
-
-       /**
-        * Some "getter" for printable choosen (checkbox) from request or session
-        *
-        * @param product Product instance
-        * @param request Request instance
-        * @param session Session instance
-        * @return Amount as string
-        */
-       public String getPrintableChoosenFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
-
-       /**
-        * Some "getter" for total price of position from request or session.
-        * Single price and amount is multiplyed.
-        *
-        * @param product Product instance
-        * @param request Request instance
-        * @param session Session instance
-        * @return Amount as string
-        */
-       public float getTotalPositionPriceFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
-
-       /**
-        * Checks whether the given product is choosen, request overules session.
-        *
-        * @param product Product instance
-        * @param request Request instance
-        * @param session Session instance
-        * @return Whether the product is choosen
-        */
-       public boolean isProductChoosen (final Product product, final HttpServletRequest request, final HttpSession session);
-
-       /**
-        * Calculates total price of all choosen products
-        *
-        * @param request Request instance
-        * @param session Session instance
-        * @return Total price of all choosen products
-        */
-       public float calculateTotalPrice (final HttpServletRequest request, final HttpSession session);
-
-       /**
-        * Calculates total amount of all choosen products
-        *
-        * @param request Request instance
-        * @param session Session instance
-        * @return Total amount of all choosen products
-        */
-       public int calculateTotalAmount (final HttpServletRequest request, final HttpSession session);
-
-       /**
-        * Some "getter" for HTML code 'checked="checked"' if the product is choosen
-        *
-        * @param product Product instance
-        * @param request Request instance
-        * @param session Session instance
-        * @return Whether the product is choosen
-        */
-       public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session);
-
-       /**
-        * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
-        *
-        * @param request Request instance
-        * @param session Session instance
-        * @return Whether the product is choosen
-        */
-       public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session);
-
-       /**
-        * Marks given product as ordered in session
-        *
-        * @param product Product to mark as ordered
-        * @param session Session instance
-        */
-       public void markProductAsOrdered(final Product product, final HttpSession session);
-
-       /**
-        * Unmarks given product as ordered in session
-        *
-        * @param product Product to unmark as ordered
-        * @param session Session instance
-        */
-       public void unmarkProductAsOrdered(final Product product, final HttpSession session);
-}
diff --git a/src/java/org/mxchange/pizzaservice/application/PizzaServiceApplication.java b/src/java/org/mxchange/pizzaservice/application/PizzaServiceApplication.java
deleted file mode 100644 (file)
index 31ce724..0000000
+++ /dev/null
@@ -1,936 +0,0 @@
-/*
- * 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.pizzaservice.application;
-
-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;
-import javax.servlet.http.HttpSession;
-import org.mxchange.jcore.BaseFrameworkSystem;
-import org.mxchange.pizzaservice.product.PizzaProduct;
-import org.mxchange.pizzaservice.product.Product;
-
-/**
- *
- * @author Roland Haeder
- */
-public class PizzaServiceApplication extends BaseFrameworkSystem implements PizzaApplication {
-       /**
-        * Main title
-        */
-       public static final String MAIN_TITLE = "Pizza-Service";
-
-       /**
-        * Product list
-        */
-       private final SortedMap<String, Product> products;
-
-       /**
-        * Some singleton getter for this instance. If the instance is not set in
-        * given application, it will be created.
-        *
-        * @param application Servlet context
-        * @return This instance
-        * @throws javax.servlet.ServletException If object is not set correctly
-        */
-       public static final PizzaApplication getInstance (final ServletContext application) throws ServletException {
-               // Trace message
-               new PizzaServiceApplication().getLogger().trace(MessageFormat.format("application={0} - CALLED!", application)); //NOI18N
-
-               if (application == null) {
-                       // Not set
-                       throw new NullPointerException("application is null"); //NOI18N
-               }
-
-                       // Init instance
-               PizzaServiceApplication instance = null;
-
-               // Get instance from servlet
-               Object object = application.getAttribute("service"); //NOI18N
-
-               // Is it set?
-               if (object instanceof PizzaServiceApplication) {
-                       // Instance is set, so casting should work
-                       instance = (PizzaServiceApplication) object;
-               } else if (object instanceof Object) {
-                       // Not correct instance
-                       throw new ServletException("service is not set correctly"); //NOI18N
-               } else {
-                       // "service" is null, so initialize it
-                       instance = new PizzaServiceApplication();
-
-                       // And set it here
-                       application.setAttribute("service", instance); //NOI18N
-               }
-
-               // Trace message
-               instance.getLogger().trace(MessageFormat.format("instance={0} - EXIT!", instance)); //NOI18N
-
-               // Return it
-               return instance;
-       }
-
-       /**
-        * Private constructor
-        */
-       private PizzaServiceApplication () {
-               // Init products instance
-               this.products = new TreeMap<>();
-
-               // Fill products list
-               this.fillProductsList();
-       }
-
-       @Override
-       public void doBootstrap () {
-               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-       }
-
-       @Override
-       public void doMainLoop () {
-               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-       }
-
-       @Override
-       public void doShutdown () {
-               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-       }
-
-       /**
-        * Getter for product (list) iterator
-        *
-        * @return An interator on all listed products
-        */
-       @Override
-       public Iterator<Map.Entry<String, Product>> getProductsIterator () {
-               assert(this.products instanceof SortedMap) : "this.products is not initialized"; //NOI18N
-               return this.products.entrySet().iterator();
-       }
-
-       /**
-        * Adds given product to list or throws an exception if name is already found
-        *
-        * @param name Internal name of product
-        * @param title Product's title
-        * @param price Price
-        */
-       private void addProduct (final String name, final String title, final float price) {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("name={0},title={1},price={2} - CALLED!", name, title, price)); //NOI18N
-
-               // Is the name already used?
-               if (this.isProductNameUsed(name)) {
-                       // Something went wrong
-                       throw new IllegalArgumentException(MessageFormat.format("product {0} is already used.", name)); //NOI18N
-               }
-
-               // Instance product
-               Product product = new PizzaProduct(name, title, price);
-
-               // 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
-        * 
-        * @param product Product instance
-        * @param session Session instance
-        * @param parameter Parameter to clear
-        */
-       private void clearSessionAttribute (final Product product, final HttpSession session, final String parameter) {
-               // Trace message
-               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.setValueInSession(product, session, parameter, null);
-
-               // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
-       }
-
-       /**
-        * Fills products list
-        * @todo Very hard-coded stuff ...
-        */
-       private void fillProductsList () {
-               // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
-
-               // Add products
-               this.addProduct("italia", "Pizza Italia", 5.50f); //NOI18N
-               this.addProduct("diablo", "Pizza Diablo", 7.80f); //NOI18N
-               this.addProduct("bolognese", "Spagetti Bolognese", 11.95f); //NOI18N
-
-               // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
-       }
-
-       /**
-        * Some getter for value from session
-        *
-        * @param product Product instance
-        * @param session Session instance
-        * @param attribute Attribute to get value from
-        * @return Value from session
-        */
-       private Object getValueFromSession (final Product product, final HttpSession session, final String attribute) {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("product={0},session={1},attribute={2} - CALLED!", product, session, attribute)); //NOI18N
-
-               // Init variable
-               Object value = null;
-
-               // Get it synced
-               synchronized (session) {
-                       value = session.getAttribute(String.format(HTTP_PARAM_MASK, product.getName(), attribute));
-               }
-
-               this.getLogger().debug(MessageFormat.format("product={0},attribute={1},value={2}", product.getName(), attribute, value)); //NOI18N
-
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("value={0} - EXIT!", value)); //NOI18N
-
-               // Return it
-               return value;
-       }
-
-       /**
-        * Checks whether given product is already used
-        *
-        * @param name Name of product
-        * @return Whether the given product's name is already used
-        */
-       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);
-       }
-
-       /**
-        * For debugging purpose
-        *
-        * @param args Arguments
-        */
-       public static void main (String[] args) {
-               // Get instance and start it
-               new PizzaServiceApplication().start();
-       }
-
-       /**
-        * Checks if the product ordered?
-        *
-        * @param product 
-        * @param session
-        * @return 
-        */
-       private boolean isProductOrdered (final Product product, final HttpSession session) {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("product={0},session={1} - CALLED!", product, session)); //NOI18N
-
-               // Get session
-               Object isOrdered = this.getValueFromSession(product, session, SESSION_ORDERED);
-               this.getLogger().debug(MessageFormat.format("product={0},isOrdered={1}", product.getName(), isOrdered)); //NOI18N
-
-               // Return result
-               return ("true".equals(isOrdered)); //NOI18N
-       }
-
-       /**
-        * Somewhat setter in session
-        *
-        * @param product Product instance
-        * @param session Session instance
-        * @param keyPart Key part to include in final key
-        * @param value Value to set
-        */
-       private void setValueInSession (final Product product, final HttpSession session, final String keyPart, final Object value) {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("product={0},session={1},keyPart={2},value={3} - CALLED!", product, session, keyPart, value)); //NOI18N
-
-               synchronized(session) {
-                       // Set it synced
-                       this.getLogger().debug(MessageFormat.format("setValueInSession: Setting value={0} for product={1},keyPart={2}", value, product.getName(), keyPart)); //NOI18N
-                       session.setAttribute(String.format(HTTP_PARAM_MASK, product.getName(), keyPart), value);
-               }
-
-               // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
-       }
-
-       /**
-        * Application starter
-        */
-       private void start () {
-               // Get iterator
-               Iterator<Map.Entry<String, Product>> iterator = this.getProductsIterator();
-
-               // Run over it
-               while (iterator.hasNext()) {
-                       // Get product instance
-                       Map.Entry<String, Product> entry = iterator.next();
-
-                       // Get value
-                       Product product = entry.getValue();
-
-                       // Output data
-                       this.getLogger().debug(MessageFormat.format("Product {0}, {1}: {2}", product.getName(), product.getTitle(), product.getPrice())); //NOI18N
-               }
-       }
-
-       /**
-        * Some "getter" for amount from session
-        * @param product Product instance
-        * @param session Session instance
-        * @return Amount as string
-        */
-       @Override
-       public String getAmountFromSession (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
-               }
-
-               // Get attribute
-               Object object = this.getValueFromSession(product, session, HTTP_PARAM_AMOUNT);
-
-               // Is the object null?
-               if (object == null) {
-                       // Trace message
-                       this.getLogger().trace("Returning 0 - EXIT!"); //NOI18N
-
-                       // Not found
-                       return "0"; //NOI18N
-               }
-
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("object={0} - EXIT!", object)); //NOI18N
-
-               // Cast to string and return it
-               return (String) object;
-       }
-
-       /**
-        * Some "getter" for choose from session
-        * 
-        * @param product Product instance
-        * @param session Session instance
-        * @return Choose as string
-        */
-       @Override
-       public String getChooseFromSession (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
-               }
-
-               // Get attribute
-               Object object = this.getValueFromSession(product, session, HTTP_PARAM_CHOOSE);
-
-               // Is the object null?
-               if (object == null) {
-                       // Not found
-                       this.getLogger().debug(MessageFormat.format("Returning empty string for product={0} ...", product.getName())); //NOI18N
-                       return ""; //NOI18N
-               }
-
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("object={0} - CALLED!", object)); //NOI18N
-
-               // Cast to string and return it
-               return (String) object;
-       }
-
-       /**
-        * Handler for amount from request or session
-        * 
-        * @param product Product instance
-        * @param request Request instance
-        * @param session Session instance
-        * @return Amount as string
-        */
-       @Override
-       public String handleAmountFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session) {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
-
-               // Is product and session set?
-               if (product == null) {
-                       // Not set
-                       throw new NullPointerException("product is null"); //NOI18N
-               } else if (request == null) {
-                       // Not set
-                       throw new NullPointerException("request is null"); //NOI18N
-               } else if (session == null) {
-                       // Not set
-                       throw new NullPointerException("session is null"); //NOI18N
-               }
-
-               // Init variabke
-               Object object;
-
-               // Check request method
-               if (!"POST".equals(request.getMethod())) { //NOI18N
-                       // Not POST, so get from session
-                       return this.getAmountFromSession(product, session);
-               } 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
-                       return "0"; //NOI18N
-               }
-
-               // Get attribute from request
-               object = request.getParameter(String.format(HTTP_PARAM_MASK, HTTP_PARAM_AMOUNT, product.getName()));
-
-               // Is it set?
-               if (object instanceof String) {
-                       // Try to parse it to integer
-                       try {
-                               Integer value = Integer.valueOf((String) object);
-                       } catch (final NumberFormatException ex) {
-                               // Not valid input
-                               this.getLogger().warn(ex);
-                               return "0"; //NOI18N
-                       }
-
-                       // Then set it in session
-                       this.setValueInSession(product, session, HTTP_PARAM_AMOUNT, object);
-
-                       // And return it
-                       return (String) object;
-               }
-
-               // Trace message
-               this.getLogger().trace("Calling getAmountFromSession() ..."); //NOI18N
-
-               // Get attribute from session
-               return this.getAmountFromSession(product, session);
-       }
-
-       /**
-        * Handler for choosen (checkbox) from request or session
-        *
-        * @param product Product instance
-        * @param request Request instance
-        * @param session Session instance
-        * @return Amount as string
-        */
-       @Override
-       public String handleChooseFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session) {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
-
-               // Is product and session set?
-               if (product == null) {
-                       // Not set
-                       throw new NullPointerException("product is null"); //NOI18N
-               } else if (request == null) {
-                       // Not set
-                       throw new NullPointerException("request is null"); //NOI18N
-               } else if (session == null) {
-                       // Not set
-                       throw new NullPointerException("session is null"); //NOI18N
-               }
-
-               // Init variabke
-               Object object;
-
-               // Check request method
-               if (!"POST".equals(request.getMethod())) { //NOI18N
-                       // Not POST, so get from session
-                       return this.getChooseFromSession(product, session);
-               } else if (this.isProductOrdered(product, session)) {
-                       // Product is ordered
-                       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
-
-               // Is it null?
-               if (object == null) {
-                       // Unset session
-                       this.getLogger().debug(MessageFormat.format("Unsetting session for product={0} ...", product.getName())); //NOI18N
-                       this.clearSessionAttribute(product, session, HTTP_PARAM_CHOOSE);
-                       this.clearSessionAttribute(product, session, HTTP_PARAM_AMOUNT);
-
-                       // Return empty string
-                       return ""; //NOI18N
-               }
-
-               // Then set it in session
-               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
-               return (String) object;
-       }
-
-       /**
-        * Some "getter" for choosen (checkbox) from session
-        *
-        * @param product Product instance
-        * @param request Request instance
-        * @param session Session instance
-        * @return Amount as string
-        */
-       @Override
-       public String getPrintableChoosenFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session) {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
-
-               // Is product and session set?
-               if (product == null) {
-                       // Not set
-                       throw new NullPointerException("product is null"); //NOI18N
-               } else if (request == null) {
-                       // Not set
-                       throw new NullPointerException("request is null"); //NOI18N
-               } else if (session == null) {
-                       // Not set
-                       throw new NullPointerException("session is null"); //NOI18N
-               }
-
-               // Get element
-               String choosen = this.handleChooseFromRequestSession(product, request, session);
-               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getName(), choosen)); //NOI18N
-
-               // Must not be null
-               assert(choosen instanceof String): "choosen is null"; //NOI18N
-
-               // Is it empty?
-               if (choosen.isEmpty()) {
-                       // Not choosen
-                       return "Nein";
-               }
-
-               // Get amount
-               String amount = this.handleAmountFromRequestSession(product, request, session);
-               this.getLogger().debug(MessageFormat.format("product={0},amount={1}", product.getName(), amount)); //NOI18N
-
-               // Must not be null
-               assert(amount instanceof String): "amount is null"; //NOI18N
-
-               // Is it empty?
-               if (amount.isEmpty() || "0".equals(amount)) { //NOI18N
-                       // Choosen, but no amount
-                       return "Nein";
-               } else {
-                       // Is choosen
-                       return "Ja";
-               }
-       }
-
-       /**
-        * Some "getter" for total price of position from request or session.
-        * Single price and amount is multiplyed.
-        *
-        * @param product Product instance
-        * @param request Request instance
-        * @param session Session instance
-        * @return Amount as string
-        */
-       @Override
-       public float getTotalPositionPriceFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session) {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
-
-               // Is product and session set?
-               if (product == null) {
-                       // Not set
-                       throw new NullPointerException("product is null"); //NOI18N
-               } else if (request == null) {
-                       // Not set
-                       throw new NullPointerException("request is null"); //NOI18N
-               } else if (session == null) {
-                       // Not set
-                       throw new NullPointerException("session is null"); //NOI18N
-               }
-
-               // Get choosen
-               String choosen = this.handleChooseFromRequestSession(product, request, session);
-               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getName(), choosen)); //NOI18N
-
-               // Must not be null
-               assert(choosen instanceof String): "choosen is null"; //NOI18N
-
-               // Is it set?
-               if (choosen.isEmpty()) {
-                       // Is empty
-                       this.getLogger().debug(MessageFormat.format("product={0},choosen={1} - returning zero ...", product.getName(), 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
-
-               // Must not be null
-               assert(amount instanceof String): "amount is null"; //NOI18N
-
-               // 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
-                       return 0.00f;
-               }
-
-               // Init variable
-               Integer value = null;
-
-               // Try it
-               try {
-                       // Get amount as integer
-                       value = Integer.valueOf(amount);
-               } catch (final NumberFormatException e) {
-                       // Bat input
-                       throw new IllegalArgumentException(e);
-               }
-
-               // Calculate price
-               float price = (product.getPrice() * value);
-
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("product={0},price={1} - EXIT!", product.getName(), price)); //NOI18N
-
-               // Then multiply it with price
-               return price;
-       }
-
-       /**
-        * Checks whether the given product is choosen, request overules session.
-        *
-        * @param product Product instance
-        * @param request Request instance
-        * @param session Session instance
-        * @return Whether the product is choosen
-        */
-       @Override
-       public boolean isProductChoosen (final Product product, final HttpServletRequest request, final HttpSession session) {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
-
-               // Is product and session set?
-               if (product == null) {
-                       // Not set
-                       throw new NullPointerException("product is null"); //NOI18N
-               } else if (request == null) {
-                       // Not set
-                       throw new NullPointerException("request is null"); //NOI18N
-               } else if (session == null) {
-                       // Not set
-                       throw new NullPointerException("session is null"); //NOI18N
-               }
-
-               // Get choosen
-               String choosen = this.handleChooseFromRequestSession(product, request, session);
-               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getName(), choosen)); //NOI18N
-
-               // Must not be null
-               assert(choosen instanceof String): "choosen is null"; //NOI18N
-
-               // Is it not choosen?
-               if (choosen.isEmpty()) {
-                       // Not choosen
-                       return false;
-               }
-
-               // Get amount
-               String amount = this.handleAmountFromRequestSession(product, request, session);
-
-               // Must not be null
-               assert(amount instanceof String): "amount is not set"; //NOI18N
-
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("amount={0} - EXIT!", amount)); //NOI18N
-
-               // Must not be empty and not 0
-               return (!amount.isEmpty() && !"0".equals(amount)); //NOI18N
-       }
-
-       /**
-        * Calculates total price of all choosen products
-        *
-        * @param request Request instance
-        * @param session Session instance
-        * @return Total price of all choosen products
-        */
-       @Override
-       public float calculateTotalPrice (final HttpServletRequest request, final HttpSession session) {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("request={0},session={1} - CALLED!", request, session)); //NOI18N
-
-               // Is product and session set?
-               if (request == null) {
-                       // Not set
-                       throw new NullPointerException("request is null"); //NOI18N
-               } else if (session == null) {
-                       // Not set
-                       throw new NullPointerException("session is null"); //NOI18N
-               }
-
-               // Init total price
-               float totalPrice = 0.00f;
-
-               // Get iterator
-               Iterator<Map.Entry<String, Product>> iterator = this.getProductsIterator();
-
-               // Walk through all products
-               while (iterator.hasNext()) {
-                       // Get entry
-                       Map.Entry<String, Product> entry = iterator.next();
-
-                       // Get product instance
-                       Product product = entry.getValue();
-
-                       // Is this choosen?
-                       if (product.isChoosen()) {
-                               // Then add product's total price
-                               this.getLogger().debug(MessageFormat.format("Calling getTotalPositionPriceFromRequestSession({0},request,session) ...", product.getName())); //NOI18N
-                               totalPrice += this.getTotalPositionPriceFromRequestSession(product, request, session);
-                       }
-                       this.getLogger().debug(MessageFormat.format("product={0},totalPrice={1}", product.getName(), totalPrice)); //NOI18N
-               }
-
-               // Trace message
-               this.getLogger().trace(MessageFormat.format(" totalPrice={0} - EXIT!", totalPrice)); //NOI18N
-
-               // Return total price
-               return totalPrice;
-       }
-
-       /**
-        * Calculates total amount of all choosen products
-        *
-        * @param request Request instance
-        * @param session Session instance
-        * @return Total amount of all choosen products
-        */
-       @Override
-       public int calculateTotalAmount (final HttpServletRequest request, final HttpSession session) {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("request={0},session={1} - CALLED!", request, session)); //NOI18N
-
-               // Is product and session set?
-               if (request == null) {
-                       // Not set
-                       throw new NullPointerException("request is null"); //NOI18N
-               } else if (session == null) {
-                       // Not set
-                       throw new NullPointerException("session is null"); //NOI18N
-               }
-
-               // Init total price
-               int totalAmount = 0;
-
-               // Get iterator
-               Iterator<Map.Entry<String, Product>> iterator = this.getProductsIterator();
-
-               // Walk through all products
-               while (iterator.hasNext()) {
-                       // Get entry
-                       Map.Entry<String, Product> entry = iterator.next();
-
-                       // Get product instance
-                       Product product = entry.getValue();
-
-                       // Is this choosen?
-                       if (product.isChoosen()) {
-                               // Then add ordered amount
-                               this.getLogger().debug(MessageFormat.format("Counting {0} ...", product.getName())); //NOI18N
-
-                               // Getting amount
-                               String amount = this.getAmountFromSession(product, session);
-
-                               // Add it up
-                               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
-               }
-
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("totalAmount={0} - EXIT!", totalAmount)); //NOI18N
-
-               // Return total price
-               return totalAmount;
-       }
-
-       /**
-        * Some "getter" for HTML code 'checked="checked"' if the product is choosen
-        *
-        * @param product Product instance
-        * @param request Request instance
-        * @param session Session instance
-        * @return Whether the product is choosen
-        */
-       @Override
-       public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session) {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
-
-               // Is product and session set?
-               if (product == null) {
-                       // Not set
-                       throw new NullPointerException("product is null"); //NOI18N
-               } else if (request == null) {
-                       // Not set
-                       throw new NullPointerException("request is null"); //NOI18N
-               } else if (session == null) {
-                       // Not set
-                       throw new NullPointerException("session is null"); //NOI18N
-               }
-
-               // First let's check if the product is choosen
-               if (this.isProductChoosen(product, request, session)) {
-                       // Trace message
-                       this.getLogger().trace("Returning checked=\"checked\" - EXIT!"); //NOI18N
-
-                       // Is choosen
-                       return "checked=\"checked\""; //NOI18N
-               } else {
-                       // Trace message
-                       this.getLogger().trace("Returning empty string - EXIT!"); //NOI18N
-
-                       // Not choosen
-                       return ""; //NOI18N
-               }
-       }
-
-       /**
-        * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
-        *
-        * @param request Request instance
-        * @param session Session instance
-        * @return Whether the product is choosen
-        */
-       @Override
-       public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session) {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("request={0},session={1} - CALLED!", request, session)); //NOI18N
-
-               // Is product and session set?
-               if (request == null) {
-                       // Not set
-                       throw new NullPointerException("request is null"); //NOI18N
-               } else if (session == null) {
-                       // Not set
-                       throw new NullPointerException("session is null"); //NOI18N
-               }
-
-               // Is something selected?
-               if (this.calculateTotalAmount(request, session) > 0) {
-                       // Trace message
-                       this.getLogger().trace("Returning empty string - EXIT!"); //NOI18N
-
-                       // Something has been choosen
-                       return ""; //NOI18N
-               } else {
-                       // Trace message
-                       this.getLogger().trace("Returning disabled=\"disabled\" - EXIT!"); //NOI18N
-
-                       // Nothing choosen yet
-                       return "disabled=\"disabled\""; //NOI18N
-               }
-       }
-
-       /**
-        * Marks given product as ordered in session
-        *
-        * @param product Product to mark as ordered
-        * @param session Session instance
-        */
-       @Override
-       public void markProductAsOrdered(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 ordered.", product.getName())); //NOI18N
-               this.setValueInSession(product, session, SESSION_ORDERED, "true"); //NOI18N
-
-               // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
-       }
-
-       /**
-        * Unmarks given product as ordered in session
-        *
-        * @param product Product to unmark as ordered
-        * @param session Session instance
-        */
-       @Override
-       public void unmarkProductAsOrdered(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("Unmarking product={0} as ordered.", product.getName())); //NOI18N
-               this.clearSessionAttribute(product, session, SESSION_ORDERED);
-
-               // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
-       }
-}
diff --git a/src/java/org/mxchange/pizzaservice/product/PizzaProduct.java b/src/java/org/mxchange/pizzaservice/product/PizzaProduct.java
deleted file mode 100644 (file)
index a287754..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * 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.pizzaservice.product;
-
-import java.text.MessageFormat;
-import org.mxchange.jcore.BaseFrameworkSystem;
-
-/**
- *
- * @author Roland Haeder
- */
-public class PizzaProduct extends BaseFrameworkSystem implements Product {
-       /**
-        * Whether this product is choosen (default: false)
-        */
-       private boolean choosen = false;
-
-       /**
-        * Name of product
-        */
-       private String name;
-
-       /**
-        * Price of product
-        */
-       private float price;
-
-       /**
-        * Title of product
-        */
-       private String title;
-
-       /**
-        * Constructor for products with a name and a price.
-        * 
-        * @param name Name of product
-        * @param title Name of product
-        * @param price Price
-        */
-       public PizzaProduct (final String name, final String title, final float price) {
-               this.setName(name);
-               this.setTitle(title);
-               this.setPrice(price);
-       }
-
-       /**
-        * Name of product
-        * @return the name
-        */
-       @Override
-       public final String getName () {
-               return this.name;
-       }
-
-       /**
-        * Name of product
-        * @param name the name to set
-        */
-       protected final void setName (final String name) {
-               this.name = name;
-       }
-
-       /**
-        * Price of product
-        * @return the price
-        */
-       @Override
-       public final float getPrice () {
-               return this.price;
-       }
-
-       /**
-        * Price of product
-        * @param price the price to set
-        */
-       protected final void setPrice (final float price) {
-               this.price = price;
-       }
-
-       /**
-        * Title of product
-        * @return the title
-        */
-       @Override
-       public final String getTitle () {
-               return this.title;
-       }
-
-       /**
-        * Title of product
-        * @param title the title to set
-        */
-       protected final void setTitle (final String title) {
-               this.title = title;
-       }
-
-       /**
-        * Whether this product is choosen (default: false)
-        *
-        * @return the choosen
-        */
-       @Override
-       public final boolean isChoosen () {
-               return this.choosen;
-       }
-
-       /**
-        * Whether this product is choosen (default: false)
-        * @param choosen the choosen to set
-        */
-       protected final void setChoosen (boolean choosen) {
-               this.choosen = choosen;
-       }
-
-       /**
-        * Marks product as choosen
-        */
-       @Override
-       public void markAsChoosen () {
-               // Set it
-               this.getLogger().debug(MessageFormat.format("product={0} marked as choosen.", this.getName()));
-               this.setChoosen(true);
-       }
-}
diff --git a/src/java/org/mxchange/pizzaservice/product/Product.java b/src/java/org/mxchange/pizzaservice/product/Product.java
deleted file mode 100644 (file)
index 71cca43..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.pizzaservice.product;
-
-import org.mxchange.jcore.FrameworkInterface;
-
-/**
- *
- * @author Roland Haeder
- */
-public interface Product extends FrameworkInterface {
-       /**
-        * Getter for name, suitable for form fields.
-        * 
-        * @return Name of product
-        */
-       public String getName ();
-
-       /**
-        * Getter for title.
-        * 
-        * @return Title of product
-        */
-       public String getTitle ();
-
-       /**
-        * Getter for raw price.
-        * 
-        * @return Single price of product
-        */
-       public float getPrice ();
-
-       /**
-        * Whether this product is choosen (default: false)
-        *
-        * @return the choosen
-        */
-       public boolean isChoosen ();
-
-       /**
-        * Marks product as choosen
-        */
-       public void markAsChoosen ();
-}
index 81001e86bcbe6b08829457039d7ba356482ec625..f58324ef1bb7cde4faf29fbe799591167e2225c7 100644 (file)
@@ -5,12 +5,13 @@
 --%>
 
 <%@page errorPage="errorHandler.jsp" %>
-<%@page import="org.mxchange.pizzaservice.application.PizzaServiceApplication"%>
+<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
 
 <!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="style.css" type="text/css"/>
                <title><%=PizzaServiceApplication.MAIN_TITLE%> - Sitzung beenden</title>
        </head>
 
index f6b957ff10e6139e747ef8395d5e86c1b28b1370..813977e0fa19bd9cf837b43ce064aaddce2bb18d 100644 (file)
@@ -4,19 +4,20 @@
        Author     : Roland Haeder
 --%>
 
-<%@page import="org.mxchange.pizzaservice.application.PizzaApplication"%>
-<%@page import="org.mxchange.pizzaservice.application.PizzaServiceApplication"%>
+<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
+<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
 <%@page import="java.io.PrintWriter"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
 <jsp:useBean id="date" class="java.util.Date" /><%
-       // Init service instance
-       PizzaApplication service = PizzaService.getInstance(application);
+       // 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="style.css" type="text/css"/>
                <title><%=PizzaServiceApplication.MAIN_TITLE%> - Fehler</title>
        </head>
 
index 2159a12875a4831a1ad67bdb02766139f74a8a48..68322e02a96816e1bd0725e1006525e7bb34bea0 100644 (file)
@@ -4,22 +4,28 @@
        Author     : Roland Haeder
 --%>
 
-<%@page import="org.mxchange.pizzaservice.application.PizzaApplication"%>
-<%@page import="org.mxchange.pizzaservice.application.PizzaServiceApplication"%>
 <%@page errorPage="errorHandler.jsp" %>
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+
 <%@page import="java.util.Map"%>
 <%@page import="java.util.Iterator"%>
-<%@page import="org.mxchange.pizzaservice.product.Product"%>
-<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
+<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
+<%@page import="org.mxchange.pizzaapplication.customer.Customer" %>
+<%@page import="org.mxchange.pizzaapplication.product.Product"%>
+
+<jsp:useBean id="customer" scope="request" class="org.mxchange.pizzaapplication.customer.bean.CustomerBean" type="Customer" />
+<jsp:setProperty name="customer" property="*" />
 
 <%
-       // Init service instance
-       PizzaApplication service = PizzaServiceApplication.getInstance(application);
+       // 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="style.css" type="text/css"/>
                <title><%=PizzaServiceApplication.MAIN_TITLE%> - Vielen Dank!</title>
        </head>
 
@@ -61,7 +67,7 @@
                                        <tbody class="table_body">
                                                <%
                                                // Get iterator from products
-                                               Iterator<Map.Entry<String, Product>> iterator = service.getProductsIterator();
+                                               Iterator<Map.Entry<String, Product>> iterator = app.getProductsIterator();
 
                                                // Iterate over all
                                                while (iterator.hasNext()) {
                                                        Product product = entry.getValue();
 
                                                        // Mark product as ordered
-                                                       service.markProductAsOrdered(product, session);
+                                                       app.markProductAsOrdered(product, session);
                                                        %>
                                                        <tr>
                                                                <td>
-                                                                       <%=service.getPrintableChoosenFromRequestSession(product, request, session)%>
+                                                                       <%=app.getPrintableChoosenFromRequestSession(product, request, session)%>
                                                                </td>
                                                                <td>
-                                                                       <%=service.handleAmountFromRequestSession(product, request, session)%>
+                                                                       <%=app.handleAmountFromRequestSession(product, request, session)%>
                                                                </td>
                                                                <td>
                                                                        <%=product.getTitle()%>
                                                                        <%=product.getPrice()%>
                                                                </td>
                                                                <td>
-                                                                       <%=service.getTotalPositionPriceFromRequestSession(product, request, session)%>
+                                                                       <%=app.getTotalPositionPriceFromRequestSession(product, request, session)%>
                                                                </td>
                                                        </tr>
                                                        <%
                                                }
-                                               float totalPrice = service.calculateTotalPrice(request, session);
+                                               float totalPrice = app.calculateTotalPrice(request, session);
                                                %>
                                                <tr>
                                                        <td id="table_total_amount_left">
                                                                Menge:
                                                        </td>
                                                        <td id="table_total_amount_right">
-                                                               <%=service.calculateTotalAmount(request, session)%>
+                                                               <%=app.calculateTotalAmount(request, session)%>
                                                        </td>
                                                        <td class="spacer">
                                                                &nbsp;
                                                <tr>
                                                        <td colspan="5" class="table_footer">
                                                                <%
-                                                               if (("POST".equals(request.getMethod())) && (service.calculateTotalAmount(request, session) > 0)) {
+                                                               if (("POST".equals(request.getMethod())) && (app.calculateTotalAmount(request, session) > 0)) {
                                                                        out.print("Ihre Bestellung ist eingegangen.");
                                                                        synchronized(session) {
-                                                                               session.invalidate();
+                                                                               //session.invalidate();
                                                                        }
                                                                } else {
                                                                        // Nothing ordered
index 70bfa5e3e81689a615d4e16344a89526a78aa545..d2c0ea7fad9894a8a49dcaa292ef516ede960c1e 100644 (file)
@@ -7,19 +7,20 @@
 <%@page errorPage="errorHandler.jsp" %>
 <%@page import="java.util.Map"%>
 <%@page import="java.util.Iterator"%>
-<%@page import="org.mxchange.pizzaservice.application.PizzaServiceApplication"%>
-<%@page import="org.mxchange.pizzaservice.application.PizzaApplication"%>
-<%@page import="org.mxchange.pizzaservice.product.Product"%>
+<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
+<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
+<%@page import="org.mxchange.pizzaapplication.product.Product"%>
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
 
 <%
-       // Init service instance
-       PizzaApplication service = PizzaServiceApplication.getInstance(application);
+       // 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="style.css" type="text/css"/>
                <title><%=PizzaServiceApplication.MAIN_TITLE%> - Eingangsseite</title>
        </head>
 
                                                        </th>
                                                </tr>
                                        </thead>
+
                                        <tbody class="table_body">
                                                <%
                                                // Get iterator from products
-                                               Iterator<Map.Entry<String, Product>> iterator = service.getProductsIterator();
+                                               Iterator<Map.Entry<String, Product>> iterator = app.getProductsIterator();
 
                                                // Iterate over all
                                                while (iterator.hasNext()) {
 
                                                        // Get product
                                                        Product product = entry.getValue();
-                                                       service.unmarkProductAsOrdered(product, session);
+                                                       app.unmarkProductAsOrdered(product, session);
                                                        %>
                                                        <tr>
                                                                <td>
-                                                                       <input type="checkbox" name="<%=String.format(PizzaApplication.HTTP_PARAM_MASK, PizzaApplication.HTTP_PARAM_CHOOSE, product.getName())%>" value="1" <%=service.getCheckedHtmlFromProduct(product, request, session)%> />
+                                                                       <input type="checkbox" name="<%=String.format(PizzaApplication.HTTP_PARAM_MASK, PizzaApplication.HTTP_PARAM_CHOOSE, product.getName())%>" 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="<%=service.getAmountFromSession(product, session)%>" size="3" maxlength="20" />
+                                                                       <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" />
                                                                </td>
                                                                <td>
                                                                        <%=product.getTitle()%>
@@ -87,6 +89,7 @@
                                                        <%
                                                }
                                                %>
+
                                                <tr>
                                                        <td colspan="4" class="table_footer">
                                                                <input type="reset" value="Formular zurücksetzen" />
index 05da6f6a8c4f5c6d80399b331e3214c7bc7c10e7..a6a3b8518017de110f85a00bb223fa369a8fff3c 100644 (file)
@@ -7,19 +7,20 @@
 <%@page errorPage="errorHandler.jsp" %>
 <%@page import="java.util.Iterator"%>
 <%@page import="java.util.Map"%>
-<%@page import="org.mxchange.pizzaservice.product.Product"%>
-<%@page import="org.mxchange.pizzaservice.application.PizzaApplication"%>
-<%@page import="org.mxchange.pizzaservice.application.PizzaServiceApplication"%>
+<%@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 service instance
-       PizzaApplication service = PizzaServiceApplication.getInstance(application);
+       // 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="style.css" type="text/css"/>
                <title><%=PizzaServiceApplication.MAIN_TITLE%> - Bestellung anzeigen</title>
        </head>
 
@@ -62,7 +63,7 @@
                                        <tbody class="table_body">
                                                <%
                                                // Get iterator from products
-                                               Iterator<Map.Entry<String, Product>> iterator = service.getProductsIterator();
+                                               Iterator<Map.Entry<String, Product>> iterator = app.getProductsIterator();
 
                                                // Iterate over all
                                                while (iterator.hasNext()) {
                                                        %>
                                                        <tr>
                                                                <td>
-                                                                       <%=service.getPrintableChoosenFromRequestSession(product, request, session)%>
+                                                                       <%=app.getPrintableChoosenFromRequestSession(product, request, session)%>
                                                                </td>
                                                                <td>
-                                                                       <%=service.handleAmountFromRequestSession(product, request, session)%>
+                                                                       <%=app.handleAmountFromRequestSession(product, request, session)%>
                                                                </td>
                                                                <td>
                                                                        <%=product.getTitle()%>
                                                                        <%=product.getPrice()%>
                                                                </td>
                                                                <td>
-                                                                       <%=service.getTotalPositionPriceFromRequestSession(product, request, session)%>
+                                                                       <%=app.getTotalPositionPriceFromRequestSession(product, request, session)%>
                                                                </td>
                                                        </tr>
                                                        <%
                                                        // Is it choosen and amount set?
-                                                       if (service.isProductChoosen(product, request, session)) {
+                                                       if (app.isProductChoosen(product, request, session)) {
                                                                // Then mark it as choosen
                                                                product.markAsChoosen();
-                                                               service.unmarkProductAsOrdered(product, session);
+                                                               app.unmarkProductAsOrdered(product, session);
                                                        }
                                                }
                                                %>
                                                                Menge:
                                                        </td>
                                                        <td id="table_total_amount_right">
-                                                               <%=service.calculateTotalAmount(request, session)%>
+                                                               <%=app.calculateTotalAmount(request, session)%>
                                                        </td>
                                                        <td class="spacer">
                                                                &nbsp;
                                                                Gesamtpreis:
                                                        </td>
                                                        <td id="table_total_sum_right">
-                                                               <%=service.calculateTotalPrice(request, session)%>
+                                                               <%=app.calculateTotalPrice(request, session)%>
+                                                       </td>
+                                               </tr>
+
+                                               <tr>
+                                                       <td colspan="5">
+                                                               <fieldset title="Bitte geben Sie Ihre Daten ein.">
+                                                                       <legend>Bitte Ihre Daten eingeben:</legend>
+
+                                                                       <div class="data_row">
+                                                                               <div class="data_left">
+                                                                                       <label for="surname">Vorname:</label>
+                                                                               </div>
+                                                                               <div class="data_right">
+                                                                                       <input type="text" id="surname" name="surname" size="10" maxlength="255" <%=app.getDisabledHtmlFromSession(request, session)%> />
+                                                                               </div>
+                                                                               <div class="clear"></div>
+                                                                       </div>
+
+                                                                       <div class="data_row">
+                                                                               <div class="data_left">
+                                                                                       <label for="family_name">Nachname:</label>
+                                                                               </div>
+                                                                               <div class="data_right">
+                                                                                       <input type="text" id="family_name" name="family_name" size="10" maxlength="255" <%=app.getDisabledHtmlFromSession(request, session)%> />
+                                                                               </div>
+                                                                               <div class="clear"></div>
+                                                                       </div>
+
+                                                                       <div class="data_row">
+                                                                               <div class="data_left">
+                                                                                       <label for="street">Straße:</label>
+                                                                               </div>
+                                                                               <div class="data_right">
+                                                                                       <input type="text" id="street" name="street" size="10" maxlength="255" <%=app.getDisabledHtmlFromSession(request, session)%> />
+                                                                               </div>
+                                                                               <div class="clear"></div>
+                                                                       </div>
+
+                                                                       <div class="data_row">
+                                                                               <div class="data_left">
+                                                                                       <label for="housenumber">Hausnummer:</label>
+                                                                               </div>
+                                                                               <div class="data_right">
+                                                                                       <input type="text" id="housenumber" name="housenumber" size="10" maxlength="255" <%=app.getDisabledHtmlFromSession(request, session)%> />
+                                                                               </div>
+                                                                               <div class="clear"></div>
+                                                                       </div>
+
+                                                                       <div class="data_row">
+                                                                               <div class="data_left">
+                                                                                       <label for="zip_code">Postleitzahl:</label>
+                                                                               </div>
+                                                                               <div class="data_right">
+                                                                                       <input type="text" id="zip_code" name="zip_code" size="5" maxlength="6" <%=app.getDisabledHtmlFromSession(request, session)%> />
+                                                                               </div>
+                                                                               <div class="clear"></div>
+                                                                       </div>
+
+                                                                       <div class="data_row">
+                                                                               <div class="data_left">
+                                                                                       <label for="city">Ort:</label>
+                                                                               </div>
+                                                                               <div class="data_right">
+                                                                                       <input type="text" id="city" name="city" size="10" maxlength="255" <%=app.getDisabledHtmlFromSession(request, session)%> />
+                                                                               </div>
+                                                                               <div class="clear"></div>
+                                                                       </div>
+
+                                                                       <div class="data_row">
+                                                                               <div class="data_left">
+                                                                                       <label for="phone_number">Telefon:</label>
+                                                                               </div>
+                                                                               <div class="data_right">
+                                                                                       <input type="text" id="phone_number" name="phone_number" size="10" maxlength="255" <%=app.getDisabledHtmlFromSession(request, session)%> />
+                                                                               </div>
+                                                                               <div class="clear"></div>
+                                                                       </div>
+                                                               </fieldset>
                                                        </td>
                                                </tr>
 
                                                <tr>
                                                        <td colspan="5" class="table_footer">
-                                                               <input type="submit" name="send" value="Bestellung abschliessen" <%=service.getDisabledHtmlFromSession(request, session)%> />
+                                                               <input type="submit" name="send" value="Bestellung abschliessen" <%=app.getDisabledHtmlFromSession(request, session)%> />
                                                        </td>
                                                </tr>
                                        </tbody>
diff --git a/web/style.css b/web/style.css
new file mode 100644 (file)
index 0000000..18c45f5
--- /dev/null
@@ -0,0 +1,25 @@
+
+.data_row {
+       width: 100%;
+}
+
+.data_left {
+       width: 100px;
+       float: left;
+}
+
+.data_right {
+       width: 100px;
+       float: right;
+}
+
+.clear {
+       clear: both;
+}
+
+/*
+ Debug only:
+div {
+       border: 1px solid #ff0000;
+}
+*/