]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Added a lot new stuff:
authorRoland Haeder <roland@mxchange.org>
Thu, 27 Aug 2015 13:33:11 +0000 (15:33 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 27 Aug 2015 13:33:11 +0000 (15:33 +0200)
- New beans added that should get rid of scriptlets (Java code within view)
- New JARs added
- jcore updated

Signed-off-by:Roland Häder <roland@mxchange.org>

49 files changed:
lib/cdi-api.jar [new file with mode: 0644]
lib/commons-lang3-3.4.jar [new file with mode: 0644]
lib/jcore.jar
nbproject/build-impl.xml
nbproject/genfiles.properties
nbproject/project.properties
nbproject/project.xml
src/java/org/mxchange/localization/bundle_de_DE.properties
src/java/org/mxchange/localization/bundle_en_US.properties
src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java
src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java
src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java
src/java/org/mxchange/pizzaapplication/basket/Basket.java
src/java/org/mxchange/pizzaapplication/basket/item/ItemBasket.java
src/java/org/mxchange/pizzaapplication/beans/CustomerBean.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/PizzaBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/PizzaServiceBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/basket/BasketBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/basket/ItemBasketBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/customer/CustomerBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java
src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketDatabaseFrontend.java
src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketFrontend.java
src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java
src/java/org/mxchange/pizzaapplication/item/AddableBasketItem.java
src/java/org/mxchange/pizzaapplication/item/BaseItem.java
src/java/org/mxchange/pizzaapplication/tags/basket/MiniBasketTag.java [new file with mode: 0644]
web/WEB-INF/tlds/basket.tld [new file with mode: 0644]
web/admin/category.jsp
web/admin/index.jsp
web/admin/product.jsp
web/bye.jsp
web/customer/login.jsp
web/customer/lost_passwd.jsp
web/customer/register.jsp
web/errorHandler.jsp
web/form_handler/add_item.jsp
web/form_handler/admin/do_category.jsp
web/form_handler/admin/do_product.jsp
web/form_handler/do_order.jsp
web/form_handler/do_preview.jsp
web/imprint.jsp
web/index.jsp
web/index.xhtml [deleted file]
web/privacy.jsp
web/static/admin/admin_category_selection_box.jsp
web/static/admin/admin_parent_category_selection_box.jsp
web/static/gender_selection_box.jsp
web/terms.jsp

diff --git a/lib/cdi-api.jar b/lib/cdi-api.jar
new file mode 100644 (file)
index 0000000..1fa239e
Binary files /dev/null and b/lib/cdi-api.jar differ
diff --git a/lib/commons-lang3-3.4.jar b/lib/commons-lang3-3.4.jar
new file mode 100644 (file)
index 0000000..8ec91d4
Binary files /dev/null and b/lib/commons-lang3-3.4.jar differ
index d75f9b63bad3754b5874cc870805afe33c6a3141..68d453786dc73ac35ef528ce3a68a76f5ba2bc4e 100644 (file)
Binary files a/lib/jcore.jar and b/lib/jcore.jar differ
index 6c45f22259f059b92e62765fdd7125d2ea400629..31465cbd90f71a2e8c020adc0cf8ef1b0e8fee1a 100644 (file)
@@ -1029,6 +1029,8 @@ exists or setup the property manually. For example like this:
         <copyfiles files="${libs.MySQLDriver.classpath}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.log4j-web-2.3.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jsfcore.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${file.reference.cdi-api.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${file.reference.commons-lang3-3.4.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <mkdir dir="${build.web.dir}/META-INF"/>
         <manifest file="${build.web.dir}/META-INF/MANIFEST.MF" mode="update"/>
     </target>
@@ -1040,6 +1042,8 @@ exists or setup the property manually. For example like this:
         <copyfiles files="${libs.MySQLDriver.classpath}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.log4j-web-2.3.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.jsfcore.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+        <copyfiles files="${file.reference.cdi-api.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+        <copyfiles files="${file.reference.commons-lang3-3.4.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
     </target>
     <target depends="init" if="dist.ear.dir" name="-clean-webinf-lib">
         <delete dir="${build.web.dir}/WEB-INF/lib"/>
index 6c0603dfa6cb0d683375b726970a51e33d34b83d..88d3fe8f9d4455252bd1b33261d003d53d36b8ad 100644 (file)
@@ -1,8 +1,8 @@
-build.xml.data.CRC32=1c5f2332
+build.xml.data.CRC32=45780b08
 build.xml.script.CRC32=a6f5a733
 build.xml.stylesheet.CRC32=651128d4@1.68.1.1
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=1c5f2332
-nbproject/build-impl.xml.script.CRC32=7b6df8a6
+nbproject/build-impl.xml.data.CRC32=45780b08
+nbproject/build-impl.xml.script.CRC32=0bccd313
 nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.68.1.1
index 491a7d92c0f8f3bd573d291e45dc500e208b824b..9d9683c28031d4df67127e9c6dab8271e22fb3b7 100644 (file)
@@ -28,7 +28,9 @@ dist.javadoc.dir=${dist.dir}/javadoc
 dist.war=${dist.dir}/${war.name}
 endorsed.classpath=
 excludes=
+file.reference.cdi-api.jar=lib\\cdi-api.jar
 file.reference.commons-codec-1.10.jar=lib/commons-codec-1.10.jar
+file.reference.commons-lang3-3.4.jar=lib\\commons-lang3-3.4.jar
 file.reference.jsfcore.jar=lib/jsfcore.jar
 file.reference.log4j-api-2.3.jar=lib/log4j-api-2.3.jar
 file.reference.log4j-core-2.3.jar=lib/log4j-core-2.3.jar
@@ -54,9 +56,11 @@ javac.classpath=\
     ${file.reference.commons-codec-1.10.jar}:\
     ${libs.MySQLDriver.classpath}:\
     ${file.reference.log4j-web-2.3.jar}:\
-    ${file.reference.jsfcore.jar}
+    ${file.reference.jsfcore.jar}:\
+    ${file.reference.cdi-api.jar}:\
+    ${file.reference.commons-lang3-3.4.jar}
 # Space-separated list of extra javac options
-javac.compilerargs=-Xlint:unchecked
+javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
 javac.debug=true
 javac.deprecation=true
 javac.processorpath=\
index 83f4832652088b02491d6ad917152eff7ca6b7c7..a09112297a151be0c4773918c1dac08fcb039d64 100644 (file)
                     <file>${file.reference.jsfcore.jar}</file>
                     <path-in-war>WEB-INF/lib</path-in-war>
                 </library>
+                <library dirs="200">
+                    <file>${file.reference.cdi-api.jar}</file>
+                    <path-in-war>WEB-INF/lib</path-in-war>
+                </library>
+                <library dirs="200">
+                    <file>${file.reference.commons-lang3-3.4.jar}</file>
+                    <path-in-war>WEB-INF/lib</path-in-war>
+                </library>
             </web-module-libraries>
             <web-module-additional-libraries/>
             <source-roots>
index f7de050362d27f4dea276b22965f814f3f0c39ff..376c558726725062742c64a5c66c296add4a835a 100644 (file)
@@ -16,3 +16,4 @@ BaseContact.gender.unknown.text=Unbekannt
 BaseContact.gender.male.text=Herr
 BaseContact.gender.female.text=Frau
 BaseContact.gender.company.text=Firma
+MiniBasketTag.basket_is_empty=Der Warenkorb ist leer.
index 0813997e1742c59347999690ad157d600846b234..d61b69f41abfad86674ac45f433647aaf1bbfe6e 100644 (file)
@@ -16,3 +16,4 @@ BaseContact.gender.unknown.text=Unknown
 BaseContact.gender.male.text=Mr.
 BaseContact.gender.female.text=Mrs.
 BaseContact.gender.company.text=Company
+MiniBasketTag.basket_is_empty=Der Warenkorb ist leer.
index 88886d5d0f823676e4828965133371e0de0cd389..38d7dd4f657755a77eb80eab8bd79cfbf17c4651 100644 (file)
@@ -70,7 +70,9 @@ public interface PizzaApplication extends Application {
         * @param product Product instance
         * @param session Session instance
         * @return Amount as string
+        * @deprecated Old code
         */
+       @Deprecated
        public String getAmountFromSession (final Product product, final HttpSession session);
 
        /**
@@ -79,7 +81,9 @@ public interface PizzaApplication extends Application {
         * @param product Product instance
         * @param session Session instance
         * @return Choose as string
+        * @deprecated Old code
         */
+       @Deprecated
        public String getChooseFromSession (final Product product, final HttpSession session);
 
        /**
@@ -89,7 +93,9 @@ public interface PizzaApplication extends Application {
         * @param request Request instance
         * @param session Session instance
         * @return Amount as string
+        * @deprecated Old code
         */
+       @Deprecated
        public String handleAmountFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
 
        /**
@@ -99,7 +105,9 @@ public interface PizzaApplication extends Application {
         * @param request Request instance
         * @param session Session instance
         * @return Amount as string
+        * @deprecated Old code
         */
+       @Deprecated
        public String getPrintableChoosenFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
 
        /**
@@ -131,7 +139,9 @@ public interface PizzaApplication extends Application {
         * @param request Request instance
         * @param session Session instance
         * @return Whether the product is choosen
+        * @deprecated Old lost code
         */
+       @Deprecated
        public boolean isProductChoosen (final Product product, final HttpServletRequest request, final HttpSession session);
 
        /**
@@ -179,7 +189,9 @@ public interface PizzaApplication extends Application {
         *
         * @param product Product to mark as ordered
         * @param session Session instance
+        * @deprecated Old code
         */
+       @Deprecated
        public void markProductAsOrdered(final Product product, final HttpSession session);
 
        /**
@@ -187,7 +199,9 @@ public interface PizzaApplication extends Application {
         *
         * @param product Product to mark as ordered
         * @param session Session instance
+        * @deprecated Old code
         */
+       @Deprecated
        public void markProductAsChoosen(final Product product, final HttpSession session);
 
        /**
@@ -195,7 +209,9 @@ public interface PizzaApplication extends Application {
         *
         * @param product Product to unmark as ordered
         * @param session Session instance
+        * @deprecated Old code
         */
+       @Deprecated
        public void unmarkProductAsOrdered(final Product product, final HttpSession session);
 
        /**
@@ -203,7 +219,9 @@ public interface PizzaApplication extends Application {
         *
         * @param product Product to unmark as choosen
         * @param session Session instance
+        * @deprecated Old code
         */
+       @Deprecated
        public void unmarkProductAsChoosen(final Product product, final HttpSession session);
 
        /**
@@ -272,7 +290,9 @@ public interface PizzaApplication extends Application {
         * @param request Request instance
         * @param session Session instance
         * @throws javax.servlet.ServletException If something unexpected happened
+        * @deprecated Old code
         */
+       @Deprecated
        public void markAllChoosenProductsAsOrdered (final HttpServletRequest request, final HttpSession session) throws ServletException;
 
        /**
index 2507b024df330c4b14191f8d5047ecfd5ddbf000..fa19b61b8676f39faaa1056382e8ef5c5f22d88f 100644 (file)
@@ -18,25 +18,20 @@ package org.mxchange.pizzaapplication.application;
 
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.sql.SQLException;
 import java.text.MessageFormat;
 import java.util.Iterator;
-import java.util.Map;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
-import org.mxchange.jcore.contact.Gender;
 import org.mxchange.jcore.exceptions.BadTokenException;
 import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException;
 import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
 import org.mxchange.pizzaapplication.BasePizzaServiceSystem;
 import org.mxchange.pizzaapplication.category.Category;
-import org.mxchange.pizzaapplication.customer.Customer;
-import org.mxchange.pizzaapplication.customer.PizzaServiceCustomer;
 import org.mxchange.pizzaapplication.database.category.PizzaCategoryDatabaseConstants;
 import org.mxchange.pizzaapplication.database.frontend.category.CategoryFrontend;
 import org.mxchange.pizzaapplication.database.frontend.category.PizzaCategoryDatabaseFrontend;
@@ -53,11 +48,6 @@ import org.mxchange.pizzaapplication.product.Product;
  * @author Roland Haeder
  */
 public class PizzaServiceApplication extends BasePizzaServiceSystem implements PizzaApplication {
-       /**
-        * Main title
-        */
-       public static final String MAIN_TITLE = "Pizza-Service";
-
        /**
         * Frontend for products
         */
@@ -68,87 +58,32 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
         */
        private CategoryFrontend categoryFrontend;
 
-       /**
-        * Some singleton getter for this instance. If the instance is not set in
-        * given application, it will be created.
-        *
-        * @param context Servlet context
-        * @return This instance
-        * @throws javax.servlet.ServletException If object is not set correctly
-        */
-       public static final PizzaApplication getInstance (final ServletContext context) throws ServletException {
-               // Check application instance
-               if (null == context) {
-                       // Not set
-                       throw new NullPointerException("application is null"); //NOI18N
-               }
-
-               // Init instance
-               PizzaApplication instance = null;
-
-               // Get instance from servlet application (aka. "application scope")
-               Object object = context.getAttribute("app"); //NOI18N
-
-               // Is it set?
-               if (object instanceof PizzaApplication) {
-                       // Instance is set, so casting should work
-                       instance = (PizzaApplication) object;
-
-                       // Debug message
-                       instance.getLogger().debug(MessageFormat.format("Using existing instance {0} ...", object)); //NOI18N
-               } else if (object instanceof Object) {
-                       // Not correct instance
-                       throw new ServletException("app is not set correctly"); //NOI18N
-               } else {
-                       try {
-                               // "service" is null, so initialize it
-                               instance = new PizzaServiceApplication();
-                               instance.init(context);
-
-                               // Debug message
-                               instance.getLogger().debug(MessageFormat.format("Created new instance {0} ...", object)); //NOI18N
-                       } catch (final UnsupportedDatabaseBackendException | SQLException | IOException | BadTokenException ex) {
-                               throw new ServletException(ex);
-                       }
-
-                       // And set it here
-                       context.setAttribute("app", instance); //NOI18N
-               }
-
+       @Override
+       public void init (final ServletContext context) throws UnsupportedDatabaseBackendException, SQLException {
                // Trace message
-               instance.getLogger().trace(MessageFormat.format("instance={0} - EXIT!", instance)); //NOI18N
+               this.getLogger().trace(MessageFormat.format("context={0} - CALLED!", context)); //NOI18N
 
-               // Return it
-               return instance;
-       }
-
-       /**
-        * For debugging purpose
-        *
-        * @param args Arguments
-        */
-       public static void main (String[] args) {
-               // Get instance and start it
-               new PizzaServiceApplication().start();
-       }
-
-       @Override
-       public void init (final ServletContext context) throws UnsupportedDatabaseBackendException, SQLException, IOException, BadTokenException {
-               // Temporary initialize default bundle
-               // @TODO The JSF may have better internatialization support
-               this.initBundle();
+               // Is the bundle initialized?
+               if (!this.isBundledInitialized()) {
+                       // Temporary initialize default bundle
+                       // @TODO The enum Gender uses this
+                       this.initBundle();
+               }
 
-               // Initialize properties from config
+               // Initialize properties from context
                this.initProperties(context);
 
                // Init database frontends
                this.initDatabaseFrontends();
+
+               // Trace message
+               this.getLogger().trace("EXIT!"); //NOI18N
        }
 
        /**
         * Default constructor
         */
-       private PizzaServiceApplication () {
+       public PizzaServiceApplication () {
        }
 
        /**
@@ -274,6 +209,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
         * @return Amount as string
         */
        @Override
+       @Deprecated
        public String getAmountFromSession (final Product product, final HttpSession session) {
                // Trace message
                this.getLogger().trace(MessageFormat.format("product={0},session={1} - CALLED!", product, session)); //NOI18N
@@ -355,6 +291,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
         * @return Choose as string
         */
        @Override
+       @Deprecated
        public String getChooseFromSession (final Product product, final HttpSession session) {
                // Trace message
                this.getLogger().trace(MessageFormat.format("product={0},session={1} - CALLED!", product, session)); //NOI18N
@@ -437,6 +374,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
         * @return Amount as string
         */
        @Override
+       @Deprecated
        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
@@ -677,6 +615,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
         * @return Amount as string
         */
        @Override
+       @Deprecated
        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
@@ -744,6 +683,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
         * @return Whether the product is choosen
         */
        @Override
+       @Deprecated
        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
@@ -794,6 +734,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
         * @param session Session instance
         */
        @Override
+       @Deprecated
        public void markAllChoosenProductsAsOrdered (final HttpServletRequest request, final HttpSession session) throws ServletException {
                // Trace message
                this.getLogger().trace(MessageFormat.format("request={0},session={1} - CALLED!", request, session)); //NOI18N
@@ -827,6 +768,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
         * @param session Session instance
         */
        @Override
+       @Deprecated
        public void markProductAsChoosen (final Product product, final HttpSession session) {
                // Trace message
                this.getLogger().trace(MessageFormat.format("product={0},session={1} - CALLED!", product, session)); //NOI18N
@@ -855,6 +797,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
         * @param session Session instance
         */
        @Override
+       @Deprecated
        public void markProductAsOrdered (final Product product, final HttpSession session) {
                // Trace message
                this.getLogger().trace(MessageFormat.format("product={0},session={1} - CALLED!", product, session)); //NOI18N
@@ -904,6 +847,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
         * @param session Session instance
         */
        @Override
+       @Deprecated
        public void unmarkProductAsChoosen (final Product product, final HttpSession session) {
                // Trace message
                this.getLogger().trace(MessageFormat.format("product={0},session={1} - CALLED!", product, session)); //NOI18N
@@ -932,6 +876,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
         * @param session Session instance
         */
        @Override
+       @Deprecated
        public void unmarkProductAsOrdered (final Product product, final HttpSession session) {
                // Trace message
                this.getLogger().trace(MessageFormat.format("product={0},session={1} - CALLED!", product, session)); //NOI18N
@@ -1091,11 +1036,17 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
         * Initializes database frontends.
         */
        private void initDatabaseFrontends () throws UnsupportedDatabaseBackendException, SQLException {
+               // Trace message
+               this.getLogger().trace("CALLED!"); //NOI18N
+
                // Product frontend
                this.productFrontend = new PizzaProductDatabaseFrontend();
 
                // Category frontend
                this.categoryFrontend = new PizzaCategoryDatabaseFrontend();
+
+               // Trace message
+               this.getLogger().trace("EXIT!"); //NOI18N
        }
 
        /**
@@ -1157,74 +1108,6 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                // Trace message
                this.getLogger().trace("EXIT!"); //NOI18N
        }
-       
-       /**
-        * Application starter
-        */
-       private void start() {
-               // Init bundle
-               this.initBundle();
-
-               try {
-                       // Init properties
-                       this.initProperties();
-
-                       // And frontends
-                       this.initDatabaseFrontends();
-               } catch (final IOException | UnsupportedDatabaseBackendException | SQLException ex) {
-                       // Abort here
-                       this.abortProgramWithException(ex);
-               }
-
-               // Init instance
-               Iterator<Product> iterator = null;
-
-               try {
-                       // Get iterator
-                       iterator = this.getAvailableProducts();
-               } catch (final ServletException ex) {
-                       this.abortProgramWithException(ex);
-               }
-
-               // "Walk" over all products
-               while ((iterator instanceof Iterator) && (iterator.hasNext())) {
-                       // Get next product
-                       Product product = iterator.next();
-
-                       // Output data
-                       this.getLogger().debug(MessageFormat.format("Product {0}, {1}: {2}", product.getItemId(), product.getTitle(), product.getPrice())); //NOI18N
-               }
-
-               // Generate fake Customer instance
-               Customer customer = new PizzaServiceCustomer();
-
-               /*
-               * Need a least a gender ... :( See, that is why I don't like default
-               * constructors, you can easily miss something important and bam! You
-               * get an NPE. The fix here is, to have construtors (or factories) which
-               * requires all required instances that needs to be set to get a
-               * consitent object back.
-               */
-               
-               // Gender is MALE now
-               customer.setGender(Gender.MALE);
-
-               // Init iterator
-               Iterator<Map.Entry<Field, Object>> it = null;
-
-               try {
-                       // Get iterator on all its fields
-                       it = customer.iterator();
-               } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
-                       this.abortProgramWithException(ex);
-               }
-
-               // Output it
-               while ((it instanceof Iterator) && (it.hasNext())) {
-                       Map.Entry<Field, Object> entry = it.next();
-                       this.getLogger().debug(MessageFormat.format("entry {0}={1}", entry.getKey(), entry.getValue())); //NOI18N
-               }
-       }
 
        /**
         * Adds given category data from request to database
index 819b853d0cc1cbea9206852526c90f0c0bd56037..85daa560ea0ba8ce91d47135963b33ff39d348aa 100644 (file)
@@ -22,10 +22,12 @@ import java.io.Serializable;
 import java.lang.reflect.InvocationTargetException;
 import java.sql.SQLException;
 import java.text.MessageFormat;
-import org.mxchange.jcore.BaseFrameworkSystem;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
 import org.mxchange.jcore.exceptions.BadTokenException;
 import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException;
 import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
+import org.mxchange.pizzaapplication.BasePizzaServiceSystem;
 import org.mxchange.pizzaapplication.database.frontend.basket.BasketDatabaseFrontend;
 import org.mxchange.pizzaapplication.database.frontend.basket.BasketFrontend;
 import org.mxchange.pizzaapplication.item.AddableBasketItem;
@@ -37,30 +39,36 @@ import org.mxchange.pizzaapplication.product.Product;
  * @author Roland Haeder
  * @param <T> Any instance that implements AddableBasketItem
  */
-public class BaseBasket<T extends AddableBasketItem> extends BaseFrameworkSystem implements Basket<T>, Serializable {
+public class BaseBasket<T extends AddableBasketItem> extends BasePizzaServiceSystem implements Basket<T>, Serializable {
        /**
         * Serial number
         */
        private static final long serialVersionUID = 784396762230845717L;
 
-       /**
-        * Session id assigned with this basket, or any other unique identifier
-        */
-       private String sessionId;
-
-       /**
-        * Protected constructor with session instance
-        * 
-        * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If an unsupported backend has been configured
-        * @throws java.sql.SQLException If an SQL error occurs
-        */
-       protected BaseBasket () throws UnsupportedDatabaseBackendException, SQLException {
+       @Override
+       public void init (final ServletContext context, final HttpSession session) throws UnsupportedDatabaseBackendException, SQLException {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().trace(MessageFormat.format("context={0} - CALLED!", context)); //NOI18N
+
+               // Is the bundle initialized?
+               if (!this.isBundledInitialized()) {
+                       // Temporary initialize default bundle
+                       // @TODO The enum Gender uses this
+                       this.initBundle();
+               }
+
+               // Initialize properties from context
+               this.initProperties(context);
 
                // Create frontend instance
                BasketFrontend frontend = new BasketDatabaseFrontend();
 
+               // Set session id here
+               this.setSessionId(session.getId());
+
+               // Set it in frontend, too
+               frontend.setSessionId(session.getId());
+
                // Debug message
                this.getLogger().debug(MessageFormat.format("frontend={0} being set ...", frontend)); //NOI18N
 
@@ -68,6 +76,17 @@ public class BaseBasket<T extends AddableBasketItem> extends BaseFrameworkSystem
                this.setFrontend(frontend);
        }
 
+       /**
+        * Protected constructor with session instance
+        * 
+        * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If an unsupported backend has been configured
+        * @throws java.sql.SQLException If an SQL error occurs
+        */
+       protected BaseBasket () throws UnsupportedDatabaseBackendException, SQLException {
+               // Trace message
+               this.getLogger().trace("CALLED!"); //NOI18N
+       }
+
        @Override
        public void addItem (final T item) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
                // Trace call
@@ -119,6 +138,12 @@ public class BaseBasket<T extends AddableBasketItem> extends BaseFrameworkSystem
                return item;
        }
 
+       @Override
+       public boolean isEmpty () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+               // Deligate call to frontend
+               return ((BasketFrontend) this.getFrontend()).isEmpty();
+       }
+
        @Override
        public boolean isItemAdded (final T item) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
                // Trace call
@@ -140,24 +165,6 @@ public class BaseBasket<T extends AddableBasketItem> extends BaseFrameworkSystem
                return isAdded;
        }
 
-       /**
-        * Setter for session id
-        *
-        * @param sessionId Session id
-        */
-       protected final void setSessionId (final String sessionId) {
-               this.sessionId = sessionId;
-       }
-
-       /**
-        * Getter for session id
-        *
-        * @return Session id
-        */
-       protected final String getSessionId () {
-               return this.sessionId;
-       }
-
        /**
         * Called when fields are set on deserialization
         *
index 5f63d07e2a4e39b6e072a256838c34bfec37491e..b583b5302521906f6125038473d7b717646c9d6e 100644 (file)
 package org.mxchange.pizzaapplication.basket;
 
 import java.io.IOException;
+import java.io.Serializable;
 import java.lang.reflect.InvocationTargetException;
 import java.sql.SQLException;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
 import org.mxchange.jcore.FrameworkInterface;
 import org.mxchange.jcore.exceptions.BadTokenException;
 import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException;
+import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
 import org.mxchange.pizzaapplication.item.AddableBasketItem;
 import org.mxchange.pizzaapplication.product.Product;
 
@@ -31,7 +35,7 @@ import org.mxchange.pizzaapplication.product.Product;
  * @author Roland Haeder
  * @param <T> Any addable basket items
  */
-public interface Basket<T extends AddableBasketItem> extends FrameworkInterface {
+public interface Basket<T extends AddableBasketItem> extends Serializable, FrameworkInterface {
 
        /**
         * Adds given item instance to this basket
@@ -46,6 +50,20 @@ public interface Basket<T extends AddableBasketItem> extends FrameworkInterface
         */
        public void addItem (final T item) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
 
+       /**
+        * Checks if the basket is empty
+        *
+        * @return Whether the basket is empty
+        * @throws java.io.IOException If an IO error occurs
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
+        * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If a corrupted database file was found
+        * @throws java.lang.NoSuchMethodException If a method was not found
+        * @throws java.lang.IllegalAccessException If the invoked method is not public
+        * @throws java.lang.reflect.InvocationTargetException If anything else happened?
+        */
+       public boolean isEmpty () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+
        /**
         * Checks whether the given item as already been added. Mostly
         * implementations may check the id number as this is mostly believed being
@@ -77,4 +95,16 @@ public interface Basket<T extends AddableBasketItem> extends FrameworkInterface
         * @throws java.lang.reflect.InvocationTargetException If anything else happened?
         */
        public AddableBasketItem getItem (final Product product) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+
+       /**
+        * Initializes this instance with given ServletContext
+        *
+        * @param context Servlet context
+        * @param session Session instance
+        * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If the backend is unsupported
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws java.io.IOException If an IO error occurs
+        * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
+        */
+       public void init (final ServletContext context, final HttpSession session) throws UnsupportedDatabaseBackendException, SQLException, IOException, BadTokenException;
 }
index e69bc5e4ddc87e1a9b9455589a91afadcf6b050d..ae34890f82dc31d76aebc0026990ced349ae7f06 100644 (file)
@@ -17,9 +17,6 @@
 package org.mxchange.pizzaapplication.basket.item;
 
 import java.sql.SQLException;
-import java.text.MessageFormat;
-import javax.servlet.http.HttpSession;
-import org.mxchange.jcore.BaseFrameworkSystem;
 import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
 import org.mxchange.pizzaapplication.basket.BaseBasket;
 import org.mxchange.pizzaapplication.basket.Basket;
@@ -29,65 +26,21 @@ import org.mxchange.pizzaapplication.item.AddableBasketItem;
  * A basket for orderable items
  *
  * @author Roland Haeder
- * @param <T> Any instance that implements AddableBasketItem
  */
-public class ItemBasket<T extends AddableBasketItem> extends BaseBasket<T> implements Basket<T> {
+public class ItemBasket extends BaseBasket<AddableBasketItem> implements Basket<AddableBasketItem> {
        /**
         * Serial number
         */
        private static final long serialVersionUID = 4384123923163957L;
 
-       /**
-        * Creates a singleton instance from given session's id
-        *
-        * @param session An instance of a HttpSession class
-        * @return A session-id based singleton instance of this basket
-        * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If an unsupported backend was configured
-        * @throws java.sql.SQLException If an SQL error occurs
-        */
-       @SuppressWarnings ("unchecked")
-       public final static Basket<AddableBasketItem> getInstance (final HttpSession session) throws UnsupportedDatabaseBackendException, SQLException {
-               // Trace message
-               BaseFrameworkSystem.getInstance().getLogger().trace(MessageFormat.format("session={0} - CALLED!", session)); //NOI18N
-
-               // Get instance
-               Basket<AddableBasketItem> basket = (Basket<AddableBasketItem>) session.getAttribute("basket"); //NOI18N
-
-               // Debug message
-               BaseFrameworkSystem.getInstance().getLogger().debug(MessageFormat.format("basket={0}", basket));
-
-               // Is the basket already created?
-               if (!(basket instanceof Basket)) {
-                       // Not yet, so create it
-                       basket = new ItemBasket<>(session);
-
-                       // Add it in session
-                       session.setAttribute("basket", basket); //NOI18N
-               }
-
-               // Return it casted
-               return basket;
-       }
-
        /**
         * Default constructor to be able to throw exceptions from super constructor
-        *
-        * @param session HttpSession instance
+        * @param context Context instance
+        * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If the backend is unsupported
+        * @throws java.sql.SQLException If an SQL error occurs
         */
-       private ItemBasket (final HttpSession session) throws UnsupportedDatabaseBackendException, SQLException {
+       public ItemBasket () throws UnsupportedDatabaseBackendException, SQLException {
                // Call super constructor
                super();
-
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("session={0} - CALLED!", session)); //NOI18N
-
-               // Session must be set
-               if (null == session) {
-                       // Session is null
-                       throw new NullPointerException("session is null");
-               }
-
-               // Set session id here
-               this.setSessionId(session.getId());
        }
 }
diff --git a/src/java/org/mxchange/pizzaapplication/beans/CustomerBean.java b/src/java/org/mxchange/pizzaapplication/beans/CustomerBean.java
deleted file mode 100644 (file)
index 4826a9b..0000000
+++ /dev/null
@@ -1,27 +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.pizzaapplication.beans;
-
-import org.mxchange.pizzaapplication.customer.Customer;
-
-/**
- * An interface for customer beans
- *
- * @author Roland Haeder
- */
-public interface CustomerBean extends Customer {
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/PizzaBean.java b/src/java/org/mxchange/pizzaapplication/beans/PizzaBean.java
new file mode 100644 (file)
index 0000000..00188ca
--- /dev/null
@@ -0,0 +1,307 @@
+/*
+ * 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.beans;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import javax.faces.FacesException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.mxchange.pizzaapplication.category.Category;
+import org.mxchange.pizzaapplication.exceptions.CategoryTitleAlreadyUsedException;
+import org.mxchange.pizzaapplication.exceptions.ProductTitleAlreadyUsedException;
+import org.mxchange.pizzaapplication.product.Product;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public interface PizzaBean extends Serializable {
+       /**
+        * Some "getter" for amount from session
+        *
+        * @param product Product instance
+        * @param session Session instance
+        * @return Amount as string
+        * @deprecated Old code
+        */
+       @Deprecated
+       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
+        * @deprecated Old code
+        */
+       @Deprecated
+       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
+        * @deprecated Old code
+        */
+       @Deprecated
+       public String handleAmountFromRequestSession (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
+        * @deprecated Old code
+        */
+       @Deprecated
+       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);
+
+       /**
+        * Initializes this instance
+        * 
+        * @throws FacesException If something was wrong
+        */
+       public void init () throws FacesException;
+
+       /**
+        * 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
+        * @deprecated Old lost code
+        */
+       @Deprecated
+       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
+        * @throws javax.servlet.ServletException If something unexpected happened
+        */
+       public float calculateTotalPrice (final HttpServletRequest request, final HttpSession session) throws ServletException;
+
+       /**
+        * Calculates total amount of all choosen products
+        *
+        * @param request Request instance
+        * @param session Session instance
+        * @return Total amount of all choosen products
+        * @throws javax.servlet.ServletException If something unexpected happened
+        */
+       public int calculateTotalAmount (final HttpServletRequest request, final HttpSession session) throws ServletException;
+
+       /**
+        * 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
+        * @throws javax.servlet.ServletException If something unexpected happened
+        */
+       public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session) throws ServletException;
+
+       /**
+        * Marks given product as ordered in session
+        *
+        * @param product Product to mark as ordered
+        * @param session Session instance
+        * @deprecated Old code
+        */
+       @Deprecated
+       public void markProductAsOrdered(final Product product, final HttpSession session);
+
+       /**
+        * Marks given product as choosen in session
+        *
+        * @param product Product to mark as ordered
+        * @param session Session instance
+        * @deprecated Old code
+        */
+       @Deprecated
+       public void markProductAsChoosen(final Product product, final HttpSession session);
+
+       /**
+        * Unmarks given product as ordered in session
+        *
+        * @param product Product to unmark as ordered
+        * @param session Session instance
+        * @deprecated Old code
+        */
+       @Deprecated
+       public void unmarkProductAsOrdered(final Product product, final HttpSession session);
+
+       /**
+        * Unmarks given product as choosen in session
+        *
+        * @param product Product to unmark as choosen
+        * @param session Session instance
+        * @deprecated Old code
+        */
+       @Deprecated
+       public void unmarkProductAsChoosen(final Product product, final HttpSession session);
+
+       /**
+        * Some getter for printable value from session or an empty string for null.
+        *
+        * @param session Session instance
+        * @param key Key to get
+        * @return Value from key, empty string for null
+        */
+       public Object getPrintableValeFromSession (final HttpSession session, final String key);
+
+       /**
+        * Somewhat setter in session
+        *
+        * @param session Session instance
+        * @param key Session key to set
+        * @param value Value to set
+        */
+       public void setValueInSession (final HttpSession session, final String key, final Object value);
+
+       /**
+        * Some "getter" for a an array of only available products
+        * 
+        * @return Only available products
+        * @throws javax.servlet.ServletException If anything went wrong
+        */
+       public Iterator<Product> getAvailableProducts () throws ServletException;
+
+       /**
+        * Some "getter" for a an array of all products
+        *
+        * @return All products
+        * @throws javax.servlet.ServletException If anything went wrong
+        */
+       public Iterator<Product> getAllProducts () throws ServletException;
+
+       /**
+        * Some "getter" for a an array of all categories
+        *
+        * @return All categories
+        * @throws javax.servlet.ServletException If anything went wrong
+        */
+       public Iterator<Category> getCategories () throws ServletException;
+
+       /**
+        * Checks if given Product instance is available and returns a printable
+        * (human-readable) string.
+        * 
+        * @param product Product instance to check
+        * @return Human-readable version of product availability
+        */
+       public String getPrintableProduktAvailability (final Product product);
+
+       /**
+        * Returns a printable (human-readable) string of product's category
+        * 
+        * @param product Product instance to check
+        * @return Human-readable version of product availability
+        * @throws javax.servlet.ServletException If something unexpected happened
+        */
+       public String getPrintableProduktCategory (final Product product) throws ServletException;
+
+       /**
+        * Marks all choosen products as ordered
+        *
+        * @param request Request instance
+        * @param session Session instance
+        * @throws javax.servlet.ServletException If something unexpected happened
+        * @deprecated Old code
+        */
+       @Deprecated
+       public void markAllChoosenProductsAsOrdered (final HttpServletRequest request, final HttpSession session) throws ServletException;
+
+       /**
+        * Adds given category data from request to database
+        *
+        * @param request Request instance
+        * @throws javax.servlet.ServletException If something unexpected happened
+        * @throws org.mxchange.pizzaapplication.exceptions.CategoryTitleAlreadyUsedException If the given title is already used
+        */
+       public void doAdminAddCategory (final HttpServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException;
+
+       /**
+        * Adds given product data from request to database
+        *
+        * @param request Request instance
+        * @throws javax.servlet.ServletException If something unexpected happened
+        * @throws org.mxchange.pizzaapplication.exceptions.ProductTitleAlreadyUsedException If the given product title is already used
+        */
+       public void doAdminAddProduct (final HttpServletRequest request) throws ServletException, ProductTitleAlreadyUsedException;
+
+       /**
+        * Generates link HTML code for given category's parent id, if set. This
+        * link then points to products.jsp?category_id=x
+        *
+        * @param category Category instance
+        * @return HTML code
+        */
+       public String generateLinkForParent (final Category category);
+
+       /**
+        * Handles admin product form requests
+        *
+        * @param request Request instance
+        * @param response Response instance
+        * @throws ServletException If something unexpected happened
+        */
+       public void doAdminHandleProductForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
+
+       /**
+        * Handles admin category form requests
+        * 
+        * @param request Request instance
+        * @param response Response instance
+        * @throws ServletException If something unexpected happened
+        */
+       public void doAdminHandleCategoryForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/PizzaServiceBean.java b/src/java/org/mxchange/pizzaapplication/beans/PizzaServiceBean.java
new file mode 100644 (file)
index 0000000..7248b7d
--- /dev/null
@@ -0,0 +1,384 @@
+/*
+ * 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.beans;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.Iterator;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.SessionScoped;
+import javax.faces.FacesException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.mxchange.jcore.exceptions.BadTokenException;
+import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
+import org.mxchange.pizzaapplication.application.PizzaApplication;
+import org.mxchange.pizzaapplication.application.PizzaServiceApplication;
+import org.mxchange.pizzaapplication.beans.basket.BasketBean;
+import org.mxchange.pizzaapplication.category.Category;
+import org.mxchange.pizzaapplication.exceptions.CategoryTitleAlreadyUsedException;
+import org.mxchange.pizzaapplication.exceptions.ProductTitleAlreadyUsedException;
+import org.mxchange.pizzaapplication.product.Product;
+
+/**
+ * Main application class
+ *
+ * @author Roland Haeder
+ */
+@Named("service")
+@SessionScoped
+public class PizzaServiceBean implements PizzaBean {
+       /**
+        * Serial id
+        */
+       private static final long serialVersionUID = 58137539530279L;
+
+       /**
+        * Servlet context
+        */
+       @Inject
+       private ServletContext application;
+
+       /**
+        * Basket instance
+        */
+       @Inject
+       private BasketBean basket;
+
+       /**
+        * Pizza application
+        */
+       private final PizzaApplication app;
+
+       /**
+        * Initializer block
+        */
+       {
+               // Get new application instance
+               this.app = new PizzaServiceApplication();
+       }
+
+       @Override
+       @PostConstruct
+       public void init () throws FacesException {
+               try {
+                       // Call init method
+                       this.app.init(this.application);
+               } catch (final UnsupportedDatabaseBackendException | SQLException | IOException | BadTokenException ex) {
+                       // Continue to throw
+                       throw new FacesException(ex);
+               }
+       }
+
+       /**
+        * Default constructor
+        */
+       public PizzaServiceBean () {
+       }
+
+       /**
+        * 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) throws ServletException {
+               return this.app.calculateTotalAmount(request, session);
+       }
+
+       /**
+        * 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) throws ServletException {
+               return this.app.calculateTotalPrice(request, session);
+       }
+
+       /**
+        * Some "getter" for amount from session
+        *
+        * @param product Product instance
+        * @param session Session instance
+        * @return Amount as string
+        */
+       @Override
+       @Deprecated
+       public String getAmountFromSession (final Product product, final HttpSession session) {
+               return this.app.getAmountFromSession(product, 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
+        */
+       @Override
+       public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session) {
+               return this.app.getCheckedHtmlFromProduct(product, request, session);
+       }
+
+       /**
+        * Some "getter" for choose from session
+        * 
+        * @param product Product instance
+        * @param session Session instance
+        * @return Choose as string
+        */
+       @Override
+       @Deprecated
+       public String getChooseFromSession (final Product product, final HttpSession session) {
+               return this.app.getChooseFromSession(product, 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
+        */
+       @Override
+       public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session) throws ServletException {
+               return this.app.getDisabledHtmlFromSession(request, session);
+       }
+
+       /**
+        * Some "getter" for choosen (checkbox) from session
+        *
+        * @param product Product instance
+        * @param request Request instance
+        * @param session Session instance
+        * @return Amount as string
+        */
+       @Override
+       @Deprecated
+       public String getPrintableChoosenFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session) {
+               return this.app.getPrintableChoosenFromRequestSession(product, request, session);
+       }
+
+       /**
+        * Checks if given Product instance is available and returns a printable
+        * (human-readable) string.
+        * 
+        * @param product Product instance to check
+        * @return Human-readable version of product availability
+        */
+       @Override
+       public String getPrintableProduktAvailability (final Product product) {
+               return this.app.getPrintableProduktAvailability(product);
+       }
+
+       /**
+        * Some getter for printable value from session or an empty string for null.
+        *
+        * @param session Session instance
+        * @param key Key to get
+        * @return Value from key, empty string for null
+        */
+       @Override
+       public Object getPrintableValeFromSession (final HttpSession session, final String key) {
+               return this.app.getPrintableValeFromSession(session, key);
+       }
+
+       /**
+        * Some "getter" for a an array of only available products
+        *
+        * @return All products
+        */
+       @Override
+       public Iterator<Product> getAvailableProducts () throws ServletException {
+               return this.app.getAvailableProducts();
+       }
+
+       /**
+        * Some "getter" for a an array of all products
+        *
+        * @return All products
+        */
+       @Override
+       public Iterator<Product> getAllProducts () throws ServletException {
+               return this.app.getAllProducts();
+       }
+
+       /**
+        * Some "getter" for a an array of all categories
+        *
+        * @return All categories
+        */
+       @Override
+       public Iterator<Category> getCategories () throws ServletException {
+               return this.app.getCategories();
+       }
+
+       /**
+        * 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) {
+               return this.app.getTotalPositionPriceFromRequestSession(product, request, session);
+       }
+
+       /**
+        * Handler for amount from request or session
+        *
+        * @param product Product instance
+        * @param request Request instance
+        * @param session Session instance
+        * @return Amount as string
+        */
+       @Override
+       @Deprecated
+       public String handleAmountFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session) {
+               return this.app.handleAmountFromRequestSession(product, request, 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
+        */
+       @Override
+       @Deprecated
+       public boolean isProductChoosen (final Product product, final HttpServletRequest request, final HttpSession session) {
+               return this.app.isProductChoosen(product, request, session);
+       }
+
+       /**
+        * Marks all choosen products as ordered
+        *
+        * @param request Request instance
+        * @param session Session instance
+        */
+       @Override
+       @Deprecated
+       public void markAllChoosenProductsAsOrdered (final HttpServletRequest request, final HttpSession session) throws ServletException {
+               this.app.markAllChoosenProductsAsOrdered(request, session);
+       }
+
+       /**
+        * Marks given product as choosen in session
+        *
+        * @param product Product to mark as ordered
+        * @param session Session instance
+        */
+       @Override
+       @Deprecated
+       public void markProductAsChoosen (final Product product, final HttpSession session) {
+               this.app.markProductAsChoosen(product, session);
+       }
+
+       /**
+        * Marks given product as ordered in session
+        *
+        * @param product Product to mark as ordered
+        * @param session Session instance
+        */
+       @Override
+       @Deprecated
+       public void markProductAsOrdered (final Product product, final HttpSession session) {
+               this.app.markProductAsOrdered(product, session);
+       }
+
+       /**
+        * Somewhat setter in session
+        *
+        * @param session Session instance
+        * @param key Session key to set
+        * @param value Value to set
+        */
+       @Override
+       public void setValueInSession (final HttpSession session, final String key, final Object value) {
+               this.app.setValueInSession(session, key, value);
+       }
+
+       /**
+        * Unmarks given product as choosen in session
+        *
+        * @param product Product to unmark as choosen
+        * @param session Session instance
+        */
+       @Override
+       @Deprecated
+       public void unmarkProductAsChoosen (final Product product, final HttpSession session) {
+               this.app.unmarkProductAsChoosen(product, session);
+       }
+
+       /**
+        * Unmarks given product as ordered in session
+        *
+        * @param product Product to unmark as ordered
+        * @param session Session instance
+        */
+       @Override
+       @Deprecated
+       public void unmarkProductAsOrdered (final Product product, final HttpSession session) {
+               this.app.unmarkProductAsOrdered(product, session);
+       }
+
+       @Override
+       public void doAdminAddCategory (final HttpServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException {
+               this.app.doAdminAddCategory(request);
+       }
+
+       @Override
+       public void doAdminAddProduct (final HttpServletRequest request) throws ServletException, ProductTitleAlreadyUsedException {
+               this.app.doAdminAddProduct(request);
+       }
+
+       @Override
+       public String generateLinkForParent (final Category category) {
+               return this.app.generateLinkForParent(category);
+       }
+
+       @Override
+       public String getPrintableProduktCategory (final Product product) throws ServletException {
+               return this.app.getPrintableProduktCategory(product);
+       }
+
+       @Override
+       public void doAdminHandleProductForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException {
+               this.app.doAdminHandleProductForms(request, response);
+       }
+
+       @Override
+       public void doAdminHandleCategoryForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException {
+               this.app.doAdminHandleCategoryForms(request, response);
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/BasketBean.java b/src/java/org/mxchange/pizzaapplication/beans/basket/BasketBean.java
new file mode 100644 (file)
index 0000000..22d1222
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * 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.beans.basket;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.sql.SQLException;
+import javax.faces.FacesException;
+import org.mxchange.jcore.exceptions.BadTokenException;
+import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException;
+import org.mxchange.pizzaapplication.item.AddableBasketItem;
+import org.mxchange.pizzaapplication.product.Product;
+
+/**
+ * An interface for a basket bean
+ *
+ * @author Roland Haeder
+ */
+public interface BasketBean extends Serializable {
+       /**
+        * Initializes this instance
+        * 
+        * @throws FacesException If something was wrong
+        */
+       public void init () throws FacesException;
+
+       /**
+        * Adds given item instance to this basket
+        * @param item Item instance to add
+        * @throws java.io.IOException If an IO error occurs
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
+        * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If a corrupted database file was found
+        * @throws java.lang.NoSuchMethodException If a method was not found
+        * @throws java.lang.IllegalAccessException If the invoked method is not public
+        * @throws java.lang.reflect.InvocationTargetException If anything else happened?
+        */
+       public void addItem (final AddableBasketItem item) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+
+       /**
+        * Checks if the basket is empty
+        *
+        * @return Whether the basket is empty
+        * @throws java.io.IOException If an IO error occurs
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
+        * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If a corrupted database file was found
+        * @throws java.lang.NoSuchMethodException If a method was not found
+        * @throws java.lang.IllegalAccessException If the invoked method is not public
+        * @throws java.lang.reflect.InvocationTargetException If anything else happened?
+        */
+       public boolean isEmpty () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+
+       /**
+        * Checks whether the given item as already been added. Mostly
+        * implementations may check the id number as this is mostly believed being
+        * unique.
+        *
+        * @param item Item instance to check
+        * @return Whether the given item has been found
+        * @throws java.io.IOException If an IO error occurs
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
+        * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If a corrupted database file was found
+        * @throws java.lang.NoSuchMethodException If a method was not found
+        * @throws java.lang.IllegalAccessException If the invoked method is not public
+        * @throws java.lang.reflect.InvocationTargetException If anything else happened?
+        */
+       public boolean isItemAdded (final AddableBasketItem item) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+
+       /**
+        * Returns an item for given product instance or null if not found.
+        * 
+        * @param product Product instance
+        * @return Item instance or null
+        * @throws java.io.IOException If an IO error occurs
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
+        * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If a corrupted database file was found
+        * @throws java.lang.NoSuchMethodException If a method was not found
+        * @throws java.lang.IllegalAccessException If the invoked method is not public
+        * @throws java.lang.reflect.InvocationTargetException If anything else happened?
+        */
+       public AddableBasketItem getItem (final Product product) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+
+       /**
+        * Getter for human-readable string from given key
+        *
+        * @param key Key to return
+        * @return Human-readable message
+        */
+       public String getMessageStringFromKey (final String key);
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/ItemBasketBean.java b/src/java/org/mxchange/pizzaapplication/beans/basket/ItemBasketBean.java
new file mode 100644 (file)
index 0000000..27a074b
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * 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.beans.basket;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.sql.SQLException;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.Dependent;
+import javax.faces.FacesException;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
+import org.mxchange.jcore.exceptions.BadTokenException;
+import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException;
+import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
+import org.mxchange.pizzaapplication.basket.Basket;
+import org.mxchange.pizzaapplication.basket.item.ItemBasket;
+import org.mxchange.pizzaapplication.item.AddableBasketItem;
+import org.mxchange.pizzaapplication.product.Product;
+
+/**
+ * A basket for orderable items
+ *
+ * @author Roland Haeder
+ */
+@Named("basket")
+@Dependent
+public class ItemBasketBean implements BasketBean {
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 4384123923163957L;
+
+       /**
+        * Servlet context
+        */
+       @Inject
+       private ServletContext application;
+
+       /**
+        * Session
+        */
+       @Inject
+       private HttpSession session;
+
+       /**
+        * Instance of wrapped basket
+        */
+       private final Basket<AddableBasketItem> basket;
+
+       /**
+        * Default constructor to be able to throw exceptions from super constructor
+        * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If the backend is unsupported
+        * @throws java.sql.SQLException If an SQL error occurs
+        */
+       public ItemBasketBean () throws UnsupportedDatabaseBackendException, SQLException {
+               // Get new application instance
+               this.basket = new ItemBasket();
+       }
+
+       @Override
+       public void addItem (final AddableBasketItem item) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+               this.basket.addItem(item);
+       }
+
+       @Override
+       public AddableBasketItem getItem (final Product product) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+               return this.basket.getItem(product);
+       }
+
+       @Override
+       public String getMessageStringFromKey (final String key) {
+               return this.basket.getMessageStringFromKey(key);
+       }
+
+       @Override
+       @PostConstruct
+       public void init () throws FacesException {
+               try {
+                       // Init instance
+                       this.basket.init(this.application, this.session);
+               } catch (final UnsupportedDatabaseBackendException | IOException | SQLException | BadTokenException ex) {
+                       // Continue to throw
+                       throw new FaceletException(ex);
+               }
+       }
+
+       @Override
+       public boolean isEmpty () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+               return this.basket.isEmpty();
+       }
+
+       @Override
+       public boolean isItemAdded (final AddableBasketItem item) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+               return this.basket.isItemAdded(item);
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerBean.java b/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerBean.java
new file mode 100644 (file)
index 0000000..12fc8fb
--- /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.beans.customer;
+
+import org.mxchange.pizzaapplication.customer.Customer;
+
+/**
+ * An interface for customer beans
+ *
+ * @author Roland Haeder
+ */
+public interface CustomerBean extends Customer {
+}
index ee40002b3f3ea9cf5183739812ea2ebf4509fc02..d2fb8d70cc40f3ebc678f7bb4da5f128fcb7ccf3 100644 (file)
@@ -24,7 +24,7 @@ import org.mxchange.jcore.client.Client;
 import org.mxchange.jcore.contact.Contact;
 import org.mxchange.jcore.contact.Gender;
 import org.mxchange.pizzaapplication.BasePizzaServiceSystem;
-import org.mxchange.pizzaapplication.beans.CustomerBean;
+import org.mxchange.pizzaapplication.beans.customer.CustomerBean;
 import org.mxchange.pizzaapplication.customer.PizzaServiceCustomer;
 
 /**
index 1d03b5622131bd22d56dea8522831b7b62caf755..fb563d84721e0301e1995c57408464e8f436ccb9 100644 (file)
@@ -199,6 +199,37 @@ public class BasketDatabaseFrontend extends BaseDatabaseFrontend implements Bask
                throw new UnsupportedOperationException(MessageFormat.format("Not supported yet: rowIndex={0}", rowIndex));
        }
 
+       @Override
+       public boolean isEmpty () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+               // Trace message
+               this.getLogger().trace("CALLED!");
+
+               // Session should be set here
+               if (this.getSessionId() == null) {
+                       // Abort here
+                       throw new NullPointerException("sessionId is null");
+               }
+
+               // Init search instance
+               SearchableCriteria criteria = new SearchCriteria();
+
+               // Add session id and product id and limit to 1
+               criteria.addCriteria(BasketDatabaseConstants.COLUMN_SESSION_ID, this.getSessionId());
+               criteria.setLimit(1);
+
+               // Get result back
+               Result<? extends Storeable> result = this.getBackend().doSelectByCriteria(criteria);
+
+               // Is it empty?
+               boolean isEmpty = (!result.hasNext());
+
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("isEmpty={0} - EXIT!", isEmpty));
+
+               // Return it
+               return isEmpty;
+       }
+
        @Override
        public boolean isItemAdded (final AddableBasketItem item, final String sessionId) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
                // Trace message
index 323fae0a86052cf44b5840d8b33176daf2a4b17e..45d5326043f0781260d4925e1754c6f7ec896816 100644 (file)
@@ -58,6 +58,20 @@ public interface BasketFrontend extends DatabaseFrontend {
         */
        public AddableBasketItem getItem (final Product product, final String sessionId) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
 
+       /**
+        * Checks if the basket is empty
+        *
+        * @return Whether the basket is empty
+        * @throws java.io.IOException If an IO error occurs
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
+        * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If a corrupted database file was found
+        * @throws java.lang.NoSuchMethodException If a method was not found
+        * @throws java.lang.IllegalAccessException If the invoked method is not public
+        * @throws java.lang.reflect.InvocationTargetException If anything else happened?
+        */
+       public boolean isEmpty () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+
        /**
         * Checks if given item instance is found in basket by its id number.
         *
index 3cfa682aa4149ed632e9b5a3f7f1e6ecaa1c5f1d..46ff6fa291cf9ff15c63ae320331923288e611ed 100644 (file)
@@ -29,9 +29,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 import org.mxchange.jcore.exceptions.BadTokenException;
 import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException;
-import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
 import org.mxchange.pizzaapplication.basket.Basket;
-import org.mxchange.pizzaapplication.basket.item.ItemBasket;
 import org.mxchange.pizzaapplication.filter.servlet.BaseServletFilter;
 import org.mxchange.pizzaapplication.item.AddableBasketItem;
 
@@ -43,6 +41,7 @@ import org.mxchange.pizzaapplication.item.AddableBasketItem;
 public class BasketItemAddedFilter extends BaseServletFilter implements Filter {
 
        @Override
+       @SuppressWarnings ("unchecked")
        public void doFilter (final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException {
                // Trace message
                this.getLogger().trace(MessageFormat.format("request={0},response={1},chain={2} - CALLED!", request, response, chain)); //NOI18N
@@ -81,7 +80,7 @@ public class BasketItemAddedFilter extends BaseServletFilter implements Filter {
                AddableBasketItem item = (AddableBasketItem) object;
 
                // Debug message
-               this.getLogger().debug(MessageFormat.format("item.id={0},item.itemId={1},item.itemType={2},item.amount={3}", item.getId(), item.getItemId(), item.getItemType(), item.getAmount()));
+               this.getLogger().debug(MessageFormat.format("item.id={0},item.itemId={1},item.itemType={2},item.amount={3}", item.getId(), item.getItemId(), item.getItemType(), item.getAmount())); //NOI18N
 
                // Init instance
                Basket<AddableBasketItem> basket;
@@ -99,7 +98,7 @@ public class BasketItemAddedFilter extends BaseServletFilter implements Filter {
                        }
 
                        // Get basket instance
-                       basket = ItemBasket.getInstance(session);
+                       basket = (Basket<AddableBasketItem>) session.getAttribute("basket"); //NOI18N
 
                        // Is the item already added?
                        if (item.getItemId() == null) {
@@ -121,7 +120,7 @@ public class BasketItemAddedFilter extends BaseServletFilter implements Filter {
 
                        // Register item with it
                        basket.addItem(item);
-               } catch (final UnsupportedDatabaseBackendException | SQLException | BadTokenException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
+               } catch (final SQLException | BadTokenException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
                        // Continue to throw
                        throw new ServletException(ex);
                }
index 12e3346b10222496aaa88a2b62fe2d97e8a5771e..a14b710afcc29415d6ef356b606f9413a8021881 100644 (file)
@@ -69,18 +69,6 @@ public interface AddableBasketItem extends Storeable, Comparable<AddableBasketIt
         */
        public void setItemType (final String type);
 
-       /**
-        * Session id
-        * @return the sessionId
-        */
-       public String getSessionId ();
-
-       /**
-        * Session id
-        * @param sessionId the sessionId to set
-        */
-       public void setSessionId (final String sessionId);
-
        /**
         * Compare method
         * @param item Item to compare to
index 43df54f8a9f156ecb4e60452c2f0a5be7d75ea3d..73d512cf004b72b75ba8c8e72689ad09d38cfd22 100644 (file)
@@ -46,11 +46,6 @@ public class BaseItem extends BaseFrameworkSystem implements AddableBasketItem {
         */
        private String itemType;
 
-       /**
-        * Session id
-        */
-       private String sessionId;
-
        @Override
        public int compareTo (final AddableBasketItem item) {
                // Trace message
@@ -145,24 +140,6 @@ public class BaseItem extends BaseFrameworkSystem implements AddableBasketItem {
                this.itemType = itemType;
        }
 
-       /**
-        * Session id
-        * @return the sessionId
-        */
-       @Override
-       public final String getSessionId () {
-               return this.sessionId;
-       }
-
-       /**
-        * Session id
-        * @param sessionId the sessionId to set
-        */
-       @Override
-       public final void setSessionId (final String sessionId) {
-               this.sessionId = sessionId;
-       }
-
        @Override
        public Object getValueFromColumn (final String columnName) throws IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
                // Trace message
diff --git a/src/java/org/mxchange/pizzaapplication/tags/basket/MiniBasketTag.java b/src/java/org/mxchange/pizzaapplication/tags/basket/MiniBasketTag.java
new file mode 100644 (file)
index 0000000..d3c36ba
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * 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.tags.basket;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.sql.SQLException;
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import org.mxchange.jcore.exceptions.BadTokenException;
+import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException;
+import org.mxchange.pizzaapplication.beans.basket.BasketBean;
+
+/**
+ * A basket tag that outputs a small basket and a link to the full basket website.
+ *
+ * @author Roland Haeder
+ */
+@SessionScoped
+public class MiniBasketTag extends BodyTagSupport {
+       /**
+        * Basket instance
+        */
+       @Inject
+       private BasketBean basket;
+
+       /**
+        * Outputs a div container with last added item + a link to the basket
+        * web page.
+        *
+        * @return No need to process the body
+        * @throws JspException If anything happens
+        */
+       @Override
+       public int doStartTag () throws JspException {
+               // Init output
+               StringBuilder out = new StringBuilder("<div class=\"mini_basket\">\n");
+
+               // basket should not be null
+               if (this.basket == null) {
+                       // Not set
+                       throw new NullPointerException("basket instance is null");
+               }
+
+               try {
+                       // Some entries found?
+                       if (this.basket.isEmpty()) {
+                               // Empty basket
+                               out.append("<div class=\"mini_basket_info\">\n");
+                               out.append(this.basket.getMessageStringFromKey("MiniBasketTag.basket_is_empty")).append("\n");
+                               out.append("</div>\n");
+                       } else {
+                               // Some times were found
+                               out.append("FOUND!");
+                       }
+               } catch (final IOException | SQLException | BadTokenException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
+                       // Continue to throw
+                       throw new JspException(ex);
+               }
+
+               // Finish output
+               out.append("</div>\n");
+
+               try {
+                       // Get output instance and write it
+                       pageContext.getOut().print(out.toString());
+               } catch (final IOException ex) {
+                       // Continue to throw
+                       throw new JspException(ex);
+               }
+
+               // Don't process any body
+               return SKIP_BODY;
+       }
+}
diff --git a/web/WEB-INF/tlds/basket.tld b/web/WEB-INF/tlds/basket.tld
new file mode 100644 (file)
index 0000000..6eed62f
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<taglib version="2.1" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd">
+       <tlib-version>1.0</tlib-version>
+       <jsp-version>1.2</jsp-version>
+       <short-name>basket</short-name>
+       <uri>http://mxchange.org/pizza-service/tags/basket</uri>
+
+       <tag>
+               <name>mini_basket</name>
+               <description>A mini basket showing latest added item and a link to the full basket web page</description>
+               <tag-class>org.mxchange.pizzaapplication.tags.basket.MiniBasketTag</tag-class>
+       </tag>
+</taglib>
index e87695986f5225c8eb0cfeae055e273bccfe54c9..3f9c0369718fd3624d711897946a94313060308a 100644 (file)
@@ -8,13 +8,13 @@
 <%--<%@page errorPage="errorHandler.jsp" %>--%>
 <%@page import="org.mxchange.pizzaapplication.category.Category"%>
 <%@page import="org.mxchange.pizzaapplication.database.category.PizzaCategoryDatabaseConstants"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%>
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
 
 <%
        // Init application instance
-       PizzaApplication app = PizzaServiceApplication.getInstance(application);
+       PizzaBean app = PizzaServiceBean.getInstance(application);
 %>
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Kategorien</title>
+               <title>Pizza-Service - Kategorien</title>
        </head>
 
        <body>
                <div id="header"> 
                        <div id="title">
-                               <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Kategorien</h1>
+                               <h1>Pizza-Service - Kategorien</h1>
                        </div>
                </div>
 
index 933a03104720c1bd845aa0f3a6aef32eabe43bcd..778b6b21174862315fb2d0ffd38a6edf9f56bc92 100644 (file)
@@ -7,27 +7,27 @@
 <%--<%@page errorPage="errorHandler.jsp" %>--%>
 <%@page import="java.util.Map"%>
 <%@page import="java.util.Iterator"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%>
 <%@page import="org.mxchange.pizzaapplication.product.Product"%>
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
 
 <%
        // Init application instance
-       PizzaApplication app = PizzaServiceApplication.getInstance(application);
+       PizzaBean app = PizzaServiceBean.getInstance(application);
 %>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Administration</title>
+               <title>Pizza-Service - Administration</title>
        </head>
 
        <body>
                <div id="header"> 
                        <div id="title">
-                               <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Administration</h1>
+                               <h1>Pizza-Service - Administration</h1>
                        </div>
                </div>
 
index 85006fcbe26d6692a540c8e9a112c765024380f9..cac2d9d93c9062c2955e1bfe843f804b6ac0e4ab 100644 (file)
 <%@page import="java.util.Map"%>
 <%@page import="org.mxchange.jcore.contact.Gender"%>
 <%@page import="org.mxchange.pizzaapplication.product.Product"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
 <%@page import="org.mxchange.pizzaapplication.database.product.PizzaProductDatabaseConstants"%>
 
 <%
        // Init application instance
-       PizzaApplication app = PizzaServiceApplication.getInstance(application);
+       PizzaBean app = PizzaServiceBean.getInstance(application);
 %>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Produkte</title>
+               <title>Pizza-Service - Produkte</title>
        </head>
 
        <body>
                <div id="header"> 
                        <div id="title">
-                               <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Produkte</h1>
+                               <h1>Pizza-Service - Produkte</h1>
                        </div>
                </div>
 
index c9bbd00baa351c3f4ce70af9b3af4de5272f7fdc..bb87fe23b7b47672728a49febad874528c22dd07 100644 (file)
@@ -5,20 +5,20 @@
 --%>
 
 <%--<%@page errorPage="errorHandler.jsp" %>--%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Sitzung beenden</title>
+               <title>Pizza-Service - Sitzung beenden</title>
        </head>
 
        <body>
                <div id="header"> 
                        <div id="title">
-                               <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Sitzung beenden</h1>
+                               <h1>Pizza-Service - Sitzung beenden</h1>
                        </div>
                </div>
 
index 48bcd46273d74bde1eb0de2f55f435b1a49ba7ab..576f73f74a2e27f8bd19b73bf88858b7e5bf242a 100644 (file)
@@ -6,20 +6,20 @@
 
 <%--<%@page errorPage="errorHandler.jsp" %>--%>
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Einloggen</title>
+               <title>Pizza-Service - Einloggen</title>
        </head>
 
        <body>
                <div id="header"> 
                        <div id="title">
-                               <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Einloggen</h1>
+                               <h1>Pizza-Service - Einloggen</h1>
                        </div>
                </div>
 
index b242e882d6eabe1595f7bd32d1aa1a0f23c0d01f..62cdae6b75b5cdb670ae48f228533eedf4131aff 100644 (file)
@@ -6,20 +6,20 @@
 
 <%--<%@page errorPage="errorHandler.jsp" %>--%>
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Passwort vergessen</title>
+               <title>Pizza-Service - Passwort vergessen</title>
        </head>
 
        <body>
                <div id="header"> 
                        <div id="title">
-                               <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Passwort vergessen</h1>
+                               <h1>Pizza-Service - Passwort vergessen</h1>
                        </div>
                </div>
 
index c3f999e3d9cfb5efc1701243f5e2f3e2e4f39e6e..1c7088ecc883a6ebaca5056e34c6d386d50f4810 100644 (file)
@@ -8,20 +8,20 @@
 
 <%--<%@page errorPage="errorHandler.jsp" %>--%>
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Neukunde</title>
+               <title>Pizza-Service - Neukunde</title>
        </head>
 
        <body>
                <div id="header"> 
                        <div id="title">
-                               <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Neukunde</h1>
+                               <h1>Pizza-Service - Neukunde</h1>
                        </div>
                </div>
 
@@ -29,7 +29,7 @@
 
                <div id="content_outer">
                        <div id="content_title">
-                               <h2>Anmelden zum <%=PizzaServiceApplication.MAIN_TITLE%>:</h2>
+                               <h2>Anmelden zum Pizza-Service:</h2>
                        </div>
 
                        <div id="content">
index 9f7dbdbf42c91dd774cdf265e839b5460508cf78..059399fd529f8adfff167a54364a0932074f80a5 100644 (file)
@@ -4,8 +4,8 @@
        Author     : Roland Haeder
 --%>
 
-<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
 <%@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" %>
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Fehler</title>
+               <title>Pizza-Service - Fehler</title>
        </head>
 
        <body>
                <div id="header"> 
                        <div id="title">
-                               <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Fehler</h1>
+                               <h1>Pizza-Service - Fehler</h1>
                        </div>
                </div>
 
index b3d8ca836f0b9f0f30101d969f7b53605dec61f6..4a9fb126f592808f4d9069f680f7519546ebaa2e 100644 (file)
@@ -6,8 +6,8 @@
 
 <%--<%@page errorPage="errorHandler.jsp" %>--%>
 <%@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.beans.PizzaBean"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
 <%@page import="org.mxchange.pizzaapplication.item.AddableBasketItem"%>
 
 <jsp:useBean id="item" scope="request" class="org.mxchange.pizzaapplication.item.basket.BasketItem" type="AddableBasketItem" />
@@ -15,7 +15,7 @@
 
 <%
        // Init application instance
-       PizzaApplication app = PizzaServiceApplication.getInstance(application);
+       PizzaBean app = PizzaServiceBean.getInstance(application);
 
        // Get amount from item
        Long amount = item.getAmount();
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Form-Handler</title>
+               <title>Pizza-Service - Form-Handler</title>
        </head>
 
        <body>
                <div id="title">
-                       <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Form-Handler</h1>
+                       <h1>Pizza-Service - Form-Handler</h1>
                </div>
 
                <jsp:include page="/static/guest/guest_menu.jsp" flush="false" />
index 8c54f09617a463f988336171ba5ff21600ca195f..ca3fa53162e3e2923bb5f8753d1c94e22df4aa69 100644 (file)
@@ -6,15 +6,15 @@
 
 <%--<%@page errorPage="errorHandler.jsp" %>--%>
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%>
 <%@page import="org.mxchange.pizzaapplication.beans.CustomerBean" %>
 <%@page import="org.mxchange.pizzaapplication.product.Product"%>
 <%@page import="org.mxchange.pizzaapplication.exceptions.CategoryTitleAlreadyUsedException"%>
 
 <%
        // Init application instance
-       PizzaApplication app = PizzaServiceApplication.getInstance(application);
+       PizzaBean app = PizzaServiceBean.getInstance(application);
 
        // Handle forms
        app.doAdminHandleCategoryForms(request, response);
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Form-Handler</title>
+               <title>Pizza-Service - Form-Handler</title>
        </head>
 
        <body>
                <div id="title">
-                       <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Form-Handler</h1>
+                       <h1>Pizza-Service - Form-Handler</h1>
                </div>
 
                <jsp:include page="/static/admin/admin_menu.jsp" flush="false" />
index 4631e09f91c0922a666b280d87ec2136ffb97014..f806c8740859ee4385740f77ea32f007c103b09a 100644 (file)
@@ -6,14 +6,14 @@
 
 <%--<%@page errorPage="errorHandler.jsp" %>--%>
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%>
 <%@page import="org.mxchange.pizzaapplication.beans.CustomerBean" %>
 <%@page import="org.mxchange.pizzaapplication.product.Product"%>
 
 <%
        // Init application instance
-       PizzaApplication app = PizzaServiceApplication.getInstance(application);
+       PizzaBean app = PizzaServiceBean.getInstance(application);
 
        // Handle forms
        app.doAdminHandleProductForms(request, response);
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Form-Handler</title>
+               <title>Pizza-Service - Form-Handler</title>
        </head>
 
        <body>
                <div id="title">
-                       <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Form-Handler</h1>
+                       <h1>Pizza-Service - Form-Handler</h1>
                </div>
 
                <jsp:include page="/static/admin/admin_menu.jsp" flush="false" />
index 1b54e633decfb482d24cd864e32acdbb052be170..a6006607bd856153901b349c4bdb63de0adbc1e9 100644 (file)
@@ -6,14 +6,14 @@
 
 <%--<%@page errorPage="errorHandler.jsp" %>--%>
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%>
 <%@page import="org.mxchange.pizzaapplication.beans.CustomerBean" %>
 <%@page import="org.mxchange.pizzaapplication.product.Product"%>
 
 <%
        // Init application instance
-       PizzaApplication app = PizzaServiceApplication.getInstance(application);
+       PizzaBean app = PizzaServiceBean.getInstance(application);
 
        // Is it post?
        if ("POST".equals(request.getMethod())) { //NOI18N
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Form-Handler</title>
+               <title>Pizza-Service - Form-Handler</title>
        </head>
 
        <body>
                <div id="title">
-                       <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Form-Handler</h1>
+                       <h1>Pizza-Service - Form-Handler</h1>
                </div>
 
                <jsp:include page="/static/guest/guest_menu.jsp" flush="false" />
index 14657f6924c4d99ef4aa16a331c30109ecf308c2..f4b7f13db1cd64476493861e24ff33730fe723e4 100644 (file)
@@ -9,14 +9,14 @@
 <%@page import="java.util.Map"%>
 <%@page import="org.mxchange.jcore.contact.Gender"%>
 <%@page import="org.mxchange.pizzaapplication.product.Product"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
 <%@page import="org.mxchange.pizzaapplication.beans.CustomerBean" %>
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
 
 <%
        // Init application instance
-       PizzaApplication app = PizzaServiceApplication.getInstance(application);
+       PizzaBean app = PizzaServiceBean.getInstance(application);
 
        // Is it post?
        if ("POST".equals(request.getMethod())) { //NOI18N
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Form-Handler</title>
+               <title>Pizza-Service - Form-Handler</title>
        </head>
 
        <body>
                <div id="title">
-                       <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Form-Handler</h1>
+                       <h1>Pizza-Service - Form-Handler</h1>
                </div>
 
                <jsp:include page="/static/guest/guest_menu.jsp" flush="false" />
index 8a5e7ed4e1837dc8f2d138a27c53a9986363c054..cd0acdb24dcd7c6f151e898c5f7350ca833cafcf 100644 (file)
@@ -5,20 +5,20 @@
 --%>
 
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Impressum</title>
+               <title>Pizza-Service - Impressum</title>
        </head>
 
        <body>
                <div id="header"> 
                        <div id="title">
-                               <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Impressum</h1>
+                               <h1>Pizza-Service - Impressum</h1>
                        </div>
                </div>
 
index a0757c000ac7115962d453e78e59c2e9ac567065..f3c27c5a7979f5b48248aaf916f157a20d65049d 100644 (file)
@@ -4,35 +4,33 @@
        Author     : Roland Haeder
 --%>
 
+<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
 <%--<%@page errorPage="errorHandler.jsp" %>--%>
 <%@page import="java.util.Map"%>
 <%@page import="java.util.Iterator"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%>
 <%@page import="org.mxchange.pizzaapplication.product.Product"%>
 <%@page import="org.mxchange.pizzaapplication.basket.Basket"%>
-<%@page import="org.mxchange.pizzaapplication.basket.item.ItemBasket"%>
 <%@page import="org.mxchange.pizzaapplication.item.basket.BasketItem"%>
 <%@page import="org.mxchange.pizzaapplication.item.AddableBasketItem"%>
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
 <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+<%@taglib prefix="basket" uri="http://mxchange.org/pizza-service/tags/basket" %>
+<jsp:useBean id="service" scope="session" class="org.mxchange.pizzaapplication.beans.PizzaServiceBean" type="org.mxchange.pizzaapplication.beans.PizzaBean" />
+<jsp:useBean id="basket" scope="session" class="org.mxchange.pizzaapplication.beans.basket.ItemBasketBean" type="org.mxchange.pizzaapplication.beans.basket.BasketBean" />
 
-<%
-       // Init application instance
-       PizzaApplication app = PizzaServiceApplication.getInstance(application);
-%>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Willkommen</title>
+               <title>Pizza-Service - Willkommen</title>
        </head>
 
        <body>
                <div id="header"> 
                        <div id="title">
-                               <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Willkommen</h1>
+                               <h1>Pizza-Service - Willkommen</h1>
                        </div>
                </div>
 
@@ -44,6 +42,8 @@
                        </div>
 
                        <div id="content">
+                               <basket:mini_basket />
+
                                <table class="table">
                                        <tr>
                                                <th class="table_header_column">
@@ -63,7 +63,7 @@
 
                                <%
                                // Get Iterator
-                               Iterator<Product> iterator = app.getAvailableProducts();
+                               Iterator<Product> iterator = service.getAvailableProducts();
 
                                // "Walk" through all products and unmark them as ordered
                                while (iterator.hasNext()) {
@@ -73,9 +73,6 @@
                                        // Debug message
                                        product.getLogger().debug("product.itemId=" + product.getItemId());
 
-                                       // Get basket instance
-                                       Basket<AddableBasketItem> basket = ItemBasket.getInstance(session);
-
                                        // Create an item instance form this product
                                        AddableBasketItem item = basket.getItem(product);
 
                                        }
 
                                        // Unmark as ordered
-                                       app.unmarkProductAsOrdered(product, session);
+                                       service.unmarkProductAsOrdered(product, session);
                                        %>
                                <form action="<%=request.getContextPath()%>/form_handler/add_item.jsp" accept-charset="utf-8" id="form" method="post">
                                <table class="table">
diff --git a/web/index.xhtml b/web/index.xhtml
deleted file mode 100644 (file)
index ae4a587..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-<?xml version='1.0' encoding='UTF-8' ?>
-<!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" xmlns:h="http://xmlns.jcp.org/jsf/html"
-         xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
-         xmlns:f="http://xmlns.jcp.org/jsf/core">
-       <ui:param name="path" value="#{request.contextPath}" />
-       <h:head>
-               <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-               <link rel="stylesheet" href="#{path}/style.css" type="text/css"/>
-               <title>Willkommen</title>
-       </h:head>
-       <h:body>
-               <div id="header"> 
-                       <div id="title">
-                               <h1>Willkommen</h1>
-                       </div>
-               </div>
-
-               <ui:include src="/static/guest/guest_menu.xhtml" id="menu" />
-
-               <div id="content_outer">
-                       <div id="content_title">
-                               <h2>Folgendes kann bestellt werden:</h2>
-                       </div>
-
-                       <div id="content">
-                               <h:panelGrid class="table" columns="4">
-                                       <h:column class="table_header_column">Bestellen?</h:column>
-                                       <h:column class="table_header_column">Anzahl:</h:column>
-                                       <h:column class="table_header_column">Produkt:</h:column>
-                                       <h:column class="table_header_column">Einzelpreis:</h:column>
-                               </h:panelGrid>
-
-                               <%
-                               // Get app instance
-                               PizzaApplication app = PizzaServiceApplication.getInstance(application);
-
-                               // Get Iterator
-                               Iterator<Product> iterator = app.getAvailableProducts();
-
-                               // "Walk" through all products and unmark them as ordered
-                               while (iterator.hasNext()) {
-                                       // Get product instance
-                                       Product product = iterator.next();
-
-                                       // Get basket instance
-                                       Basket<AddableBasketItem> basket = ItemBasket.getInstance(session);
-
-                                       // Create an item instance form this product
-                                       AddableBasketItem item = basket.getItem(product);
-
-                                       // Has it been already added to the basket?
-                                       if (item != null) {
-                                               // Some nice output ...
-                                               %>
-                               <h:panelGrid class="table" columns="4">
-                                       <h:column class="table_header_column"><a href="#{path}/basket.jsp" title="Zum Warenkorb">Warenkorb</a></h:column>
-                                       <h:column class="table_header_column"><%=item.getAmount()%></h:column>
-                                       <h:column class="table_header_column"><%=product.getTitle()%></h:column>
-                                       <h:column class="table_header_column"><f:convertNumber type="currency"><%=product.getPrice()%></f:convertNumber></h:column>
-                               </h:panelGrid>
-                                               <%
-                                               // Then skip this item
-                                               continue;
-                                       }
-
-                                       // Unmark as ordered
-                                       app.unmarkProductAsOrdered(product, session);
-                                       %>
-                               <h:form>
-                               <h:panelGrid class="table" columns="4">
-                                       <h:column class="table_header_column">
-                                               <h:commandButton action="#{path}/form_handler/add_item.jsp" class="submit" value="Hinzuf&uuml;gen" />
-                                               <input class="input" type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_ID%>" value="<%=product.getItemId()%>" />
-                                               <input class="input" type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_TYPE%>" value="Product" />
-                                       </h:column>
-                                       <h:column class="table_header_column">
-                                               <!--<h:inputText class="input" size="3" maxlength="20" />-->
-                                               <input class="input" type="text" name="<%=PizzaApplication.HTTP_PARAM_AMOUNT%>" size="3" maxlength="20" />
-                                       </h:column>
-                                       <h:column class="table_header_column">
-                                               <%=product.getTitle()%>
-                                       </h:column>
-                                       <h:column class="table_header_column right">
-                                               <f:convertNumber type="currency"><%=product.getPrice()%></f:convertNumber>
-                                       </h:column>
-                               </h:panelGrid>
-                               </h:form>
-                               <%
-                       }
-                       %>
-                       </div>
-               </div>
-
-               <ui:include src="/static/guest/guest_footer.xhtml" id="footer" />
-
-       </h:body>
-</html>
index 9ed1ddffe6c545bbdfa0642516073a2d246b01cb..00c02e3ac05a2e720773582fa5de86cc369c1814 100644 (file)
@@ -6,20 +6,20 @@
 
 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Datenschutzbestimmungen</title>
+               <title>Pizza-Service - Datenschutzbestimmungen</title>
        </head>
 
        <body>
                <div id="header"> 
                        <div id="title">
-                               <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Datenschutzbestimmungen</h1>
+                               <h1>Pizza-Service - Datenschutzbestimmungen</h1>
                        </div>
                </div>
 
index 39cbeab136eee8237e9a7865c60dd3c027db6017..908bc07290e5437422e61e4dcbe09e1ceffe9ad3 100644 (file)
@@ -6,16 +6,12 @@
 
 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@page import="org.mxchange.pizzaapplication.database.category.PizzaCategoryDatabaseConstants"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
-
-<%
-       // Init application instance
-       PizzaApplication app = PizzaServiceApplication.getInstance(application);
-%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%>
+<jsp:useBean id="service" scope="session" class="org.mxchange.pizzaapplication.beans.PizzaServiceBean" type="org.mxchange.pizzaapplication.beans.PizzaBean" />
 
 <select class="select" name="category" size="1">
-       <c:forEach var="category" items="<%=app.getCategories()%>">
+       <c:forEach var="category" items="<%=service.getCategories()%>">
                <option value="${category.getCategoryId()}">${category.decodedTitle()}</option>
        </c:forEach>
 </select>
index 2004c8833b5f2107b18fabebf710097bda8fe6ea..877396a6820149499757f539e4b1dc497c894043 100644 (file)
@@ -6,17 +6,13 @@
 
 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@page import="org.mxchange.pizzaapplication.database.category.PizzaCategoryDatabaseConstants"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
-
-<%
-       // Init application instance
-       PizzaApplication app = PizzaServiceApplication.getInstance(application);
-%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%>
+<jsp:useBean id="service" scope="session" class="org.mxchange.pizzaapplication.beans.PizzaServiceBean" type="org.mxchange.pizzaapplication.beans.PizzaBean" />
 
 <select class="select" name="<%=PizzaCategoryDatabaseConstants.COLUMN_PARENT%>" size="1">
        <option value="">Ist oberste Kategorie</option>
-       <c:forEach var="category" items="<%=app.getCategories()%>">
+       <c:forEach var="category" items="<%=service.getCategories()%>">
                <option value="${category.getCategoryId()}">${category.decodedTitle()}</option>
        </c:forEach>
 </select>
index dfd0a2f99c6026d3dbdfcafd4c0e80a4aa482680..615ef9e9a090b8672eaee56f2d57f938b0ff16f5 100644 (file)
@@ -4,18 +4,14 @@
        Author     : Roland Haeder
 --%>
 <%@page import="org.mxchange.jcore.contact.Gender"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
-<%@page import="org.mxchange.pizzaapplication.beans.CustomerBean" %>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%>
+<%@page import="org.mxchange.pizzaapplication.beans.customer.CustomerBean" %>
 
 <jsp:useBean id="customer" scope="session" class="org.mxchange.pizzaapplication.customer.bean.PizzaServiceCustomerBean" type="CustomerBean" />
+<jsp:useBean id="service" scope="session" class="org.mxchange.pizzaapplication.beans.PizzaServiceBean" type="org.mxchange.pizzaapplication.beans.PizzaBean" />
 
-<%
-       // Init application instance
-       PizzaApplication app = PizzaServiceApplication.getInstance(application);
-%>
-
-<select class="select" name="gender" id="gender" size="1" <%=app.getDisabledHtmlFromSession(request, session)%>>
+<select class="select" name="gender" id="gender" size="1" <%=service.getDisabledHtmlFromSession(request, session)%>>
        <%
        // "Walk" through all genders and output them
        for (final Gender gender : Gender.values()) {
index 506e7f89d736c38d63b77d4539048978e5d2902a..bbd11465ed9cc502fa56558a0da1ddaac4bb9760 100644 (file)
@@ -6,20 +6,20 @@
 
 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
-<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
+<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%>
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
-               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Allgemeine Geschäftsbedingungen</title>
+               <title>Pizza-Service - Allgemeine Geschäftsbedingungen</title>
        </head>
 
        <body>
                <div id="header"> 
                        <div id="title">
-                               <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Allgemeine Geschäftsbedingungen</h1>
+                               <h1>Pizza-Service - Allgemeine Geschäftsbedingungen</h1>
                        </div>
                </div>