]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Refacturing towards JSF:
authorRoland Haeder <roland@mxchange.org>
Tue, 1 Sep 2015 13:26:42 +0000 (15:26 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 1 Sep 2015 13:28:15 +0000 (15:28 +0200)
- Well, this sucks a bit: getAvailableProducts() needs to return something that is Collection and not Iterator (which worked in JSP)
- Added initial index.xhtml and CSS layout for upcoming rewrite (origin: NetBeans)
- updated jcore/jshop

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

23 files changed:
lib/jcore.jar
lib/jshop.jar
nbproject/faces-config.NavData [new file with mode: 0644]
nbproject/project.properties
src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java
src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java
src/java/org/mxchange/pizzaapplication/beans/controller/PizzaBean.java
src/java/org/mxchange/pizzaapplication/beans/controller/PizzaServiceBean.java
src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java
src/java/org/mxchange/pizzaapplication/tags/basket/MiniBasketTag.java
web/WEB-INF/faces-config.xml [new file with mode: 0644]
web/WEB-INF/templates/base.tpl [new file with mode: 0644]
web/WEB-INF/templates/guest/guest_footer.tpl [new file with mode: 0644]
web/WEB-INF/templates/guest/guest_menu.tpl [new file with mode: 0644]
web/WEB-INF/web.xml
web/admin/category.jsp
web/admin/product.jsp
web/index.jsp
web/index.xhtml [new file with mode: 0644]
web/resources/css/cssLayout.css [new file with mode: 0644]
web/resources/css/default.css [new file with mode: 0644]
web/static/admin/admin_category_selection_box.jsp
web/static/admin/admin_parent_category_selection_box.jsp

index 8b05d574954f3d02853e6d4a7108c1987006d686..f2672bd2d64abe828581866c58440a7f7c591b5c 100644 (file)
Binary files a/lib/jcore.jar and b/lib/jcore.jar differ
index e6c9d7bd41193690feb057d1bf14c9ba02cd19f0..26abcd4cd3482e53d79dfe3a2a43deee8acff6f4 100644 (file)
Binary files a/lib/jshop.jar and b/lib/jshop.jar differ
diff --git a/nbproject/faces-config.NavData b/nbproject/faces-config.NavData
new file mode 100644 (file)
index 0000000..e69de29
index b8c865913b9bb115920d9dc85512c6be752e09fb..6836c4a1f606fc862cf1e572d69b7a41969d7b3c 100644 (file)
@@ -3,6 +3,7 @@ annotation.processing.enabled.in.editor=true
 annotation.processing.processors.list=
 annotation.processing.run.all.processors=true
 annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+auxiliary.org-netbeans-modules-html-editor-lib.default-xhtml-public-id=-//W3C//DTD XHTML 1.0 Transitional//EN
 auxiliary.org-netbeans-modules-projectapi.jsf_2e_language=Facelets
 build.classes.dir=${build.web.dir}/WEB-INF/classes
 build.classes.excludes=**/*.java,**/*.form
index 051ddcd99ae653075b271f7eb0df731581eb1355..aa400cea89b2fdc8a9fe1905e1b1d25cd19b0902 100644 (file)
@@ -18,6 +18,7 @@ package org.mxchange.pizzaapplication.application;
 
 import java.io.IOException;
 import java.sql.SQLException;
+import java.util.Deque;
 import java.util.Iterator;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
@@ -52,6 +53,30 @@ public interface PizzaApplication extends Application {
        @Deprecated
        static final String HTTP_PARAM_MASK = "%s[%s]"; //NOI18N
 
+       /**
+        * Some "getter" for a linked list of only available products
+        * 
+        * @return Only available products
+        * @throws javax.servlet.ServletException If anything went wrong
+        */
+       public Deque<Product> getAvailableProducts () throws ServletException;
+
+       /**
+        * Some "getter" for a linked list of all products
+        *
+        * @return All products
+        * @throws javax.servlet.ServletException If anything went wrong
+        */
+       public Deque<Product> getAllProducts () throws ServletException;
+
+       /**
+        * Some "getter" for a linked list of all categories
+        *
+        * @return All categories
+        * @throws javax.servlet.ServletException If anything went wrong
+        */
+       public Deque<Category> getAllCategories () throws ServletException;
+
        /**
         * Initializes this instance with given ServletContext
         *
@@ -98,7 +123,7 @@ public interface PizzaApplication extends Application {
         * @return Only available products
         * @throws javax.servlet.ServletException If anything went wrong
         */
-       public Iterator<Product> getAvailableProducts () throws ServletException;
+       public Iterator<Product> getAvailableProductsIterator () throws ServletException;
 
        /**
         * Some "getter" for a an array of all products
@@ -106,7 +131,7 @@ public interface PizzaApplication extends Application {
         * @return All products
         * @throws javax.servlet.ServletException If anything went wrong
         */
-       public Iterator<Product> getAllProducts () throws ServletException;
+       public Iterator<Product> getAllProductsIterator () throws ServletException;
 
        /**
         * Some "getter" for a an array of all categories
@@ -114,7 +139,7 @@ public interface PizzaApplication extends Application {
         * @return All categories
         * @throws javax.servlet.ServletException If anything went wrong
         */
-       public Iterator<Category> getAllCategories () throws ServletException;
+       public Iterator<Category> getAllCategoriesIterator () throws ServletException;
 
        /**
         * Checks if given Product instance is available and returns a printable
index a5e35eb3317f34af7194bbbbc075c558dd2fbc27..9bf32b496dc024ae15d3de1f897d46738e5cd5ac 100644 (file)
@@ -21,6 +21,7 @@ import java.io.UnsupportedEncodingException;
 import java.lang.reflect.InvocationTargetException;
 import java.sql.SQLException;
 import java.text.MessageFormat;
+import java.util.Deque;
 import java.util.Iterator;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
@@ -50,12 +51,12 @@ import org.mxchange.pizzaapplication.BasePizzaServiceSystem;
  */
 public class PizzaServiceApplication extends BasePizzaServiceSystem implements PizzaApplication {
        /**
-        * Frontend for products
+        * Database frontend for products
         */
        private ProductFrontend productFrontend;
 
        /**
-        * Frontend for categories
+        * Database frontend for categories
         */
        private CategoryFrontend categoryFrontend;
 
@@ -67,6 +68,39 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace("CALLED!"); //NOI18N
        }
 
+       @Override
+       public Deque<Category> getAllCategories () throws ServletException {
+               try {
+                       // Deligate to frontend
+                       return this.categoryFrontend.getAllCategories();
+               } catch (final IOException | BadTokenException | SQLException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
+                       // Continue to throw
+                       throw new ServletException(ex);
+               }
+       }
+
+       @Override
+       public Deque<Product> getAllProducts () throws ServletException {
+               try {
+                       // Deligate to frontend
+                       return this.productFrontend.getAllProducts();
+               } catch (final IOException | BadTokenException | SQLException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
+                       // Continue to throw
+                       throw new ServletException(ex);
+               }
+       }
+
+       @Override
+       public Deque<Product> getAvailableProducts () throws ServletException {
+               try {
+                       // Deligate to frontend
+                       return this.productFrontend.getAllAvailableProducts();
+               } catch (final IOException | BadTokenException | SQLException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
+                       // Continue to throw
+                       throw new ServletException(ex);
+               }
+       }
+
        @Override
        public void init (final ServletContext context) throws UnsupportedDatabaseBackendException, SQLException {
                // Trace message
@@ -119,7 +153,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
 
                // Init/declare total price and iterator
                int totalAmount = 0;
-               Iterator<Product> iterator = this.getAvailableProducts();
+               Iterator<Product> iterator = this.getAvailableProductsIterator();
 
                // "Walk" over all products
                while (iterator.hasNext()) {
@@ -295,7 +329,8 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
        }
 
        @Override
-       public Iterator<Product> getAvailableProducts () throws ServletException {
+       @SuppressWarnings ("unchecked")
+       public Iterator<Product> getAvailableProductsIterator () throws ServletException {
                // categoryFrontend must be set
                if (null == this.productFrontend) {
                        // Abort here
@@ -304,14 +339,15 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
 
                try {
                        // Ask frontend for a list of products
-                       return this.productFrontend.getAvailableProducts();
+                       return (Iterator<Product>) this.productFrontend.getAvailableProductsIterator();
                } catch (final IOException | BadTokenException | SQLException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
                        throw new ServletException(ex);
                }
        }
 
        @Override
-       public Iterator<Product> getAllProducts () throws ServletException {
+       @SuppressWarnings ("unchecked")
+       public Iterator<Product> getAllProductsIterator () throws ServletException {
                // Trace message
                this.getLogger().trace("CALLED!"); //NOI18N
 
@@ -323,14 +359,15 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
 
                try {
                        // Ask frontend for a list of products
-                       return this.productFrontend.getAllProducts();
+                       return (Iterator<Product>) this.productFrontend.getAllProductsIterator();
                } catch (final IOException | BadTokenException | SQLException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
                        throw new ServletException(ex);
                }
        }
 
        @Override
-       public Iterator<Category> getAllCategories () throws ServletException {
+       @SuppressWarnings ("unchecked")
+       public Iterator<Category> getAllCategoriesIterator () throws ServletException {
                // Trace message
                this.getLogger().trace("CALLED!"); //NOI18N
 
@@ -342,7 +379,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
 
                try {
                        // Ask frontend for a list of categories
-                       return this.categoryFrontend.getAllCategories();
+                       return (Iterator<Category>) this.categoryFrontend.getAllCategoriesIterator();
                } catch (final IOException | BadTokenException | SQLException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
                        throw new ServletException(ex);
                }
index 1a7eda3f09ef93b6f88aaa535d92b24ce180fcda..18bed800e96b98a921add576836d0399aebf5f8e 100644 (file)
@@ -16,6 +16,7 @@
  */
 package org.mxchange.pizzaapplication.beans.controller;
 
+import java.util.Deque;
 import java.util.Iterator;
 import javax.faces.FacesException;
 import javax.servlet.ServletException;
@@ -70,28 +71,52 @@ public interface PizzaBean extends FrameworkBean {
        public void setValueInSession (final HttpSession session, final String key, final Object value);
 
        /**
-        * Some "getter" for a an array of only available products
+        * Some "getter" for an iterator of only available products
         * 
         * @return Only available products
         * @throws javax.servlet.ServletException If anything went wrong
         */
-       public Iterator<Product> getAvailableProducts () throws ServletException;
+       public Iterator<Product> getAvailableProductsIterator () throws ServletException;
 
        /**
-        * Some "getter" for a an array of all products
+        * Some "getter" for an iterator of all products
         *
         * @return All products
         * @throws javax.servlet.ServletException If anything went wrong
         */
-       public Iterator<Product> getAllProducts () throws ServletException;
+       public Iterator<Product> getAllProductsIterator () throws ServletException;
 
        /**
-        * Some "getter" for a an array of all categories
+        * Some "getter" for an iterator of all categories
         *
         * @return All categories
         * @throws javax.servlet.ServletException If anything went wrong
         */
-       public Iterator<Category> getAllCategories () throws ServletException;
+       public Iterator<Category> getAllCategoriesIterator () throws ServletException;
+
+       /**
+        * Some "getter" for a linked list of only available products
+        * 
+        * @return Only available products
+        * @throws javax.servlet.ServletException If anything went wrong
+        */
+       public Deque<Product> getAvailableProducts () throws ServletException;
+
+       /**
+        * Some "getter" for a linked list of all products
+        *
+        * @return All products
+        * @throws javax.servlet.ServletException If anything went wrong
+        */
+       public Deque<Product> getAllProducts () throws ServletException;
+
+       /**
+        * Some "getter" for a linked list of all categories
+        *
+        * @return All categories
+        * @throws javax.servlet.ServletException If anything went wrong
+        */
+       public Deque<Category> getAllCategories () throws ServletException;
 
        /**
         * Checks if given Product instance is available and returns a printable
index 86b100971158ca156601ee42ea85e313a983f82d..a61838d646be21a93b67b228e1f9c15f9dc28fbb 100644 (file)
@@ -19,6 +19,7 @@ package org.mxchange.pizzaapplication.beans.controller;
 import java.io.IOException;
 import java.sql.SQLException;
 import java.text.MessageFormat;
+import java.util.Deque;
 import java.util.Iterator;
 import javax.annotation.PostConstruct;
 import javax.enterprise.context.SessionScoped;
@@ -93,80 +94,51 @@ public class PizzaServiceBean extends BaseFrameworkBean implements PizzaBean {
                }
        }
 
-       /**
-        * 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 ServletRequest request, final HttpSession session) {
                return this.app.getCheckedHtmlFromProduct(product, request, 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 ServletRequest request, final HttpSession session) throws ServletException {
                return this.app.getDisabledHtmlFromSession(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 a an array of only available products
-        *
-        * @return All products
-        */
        @Override
-       public Iterator<Product> getAvailableProducts () throws ServletException {
+       public Iterator<Product> getAvailableProductsIterator () throws ServletException {
+               return this.app.getAvailableProductsIterator();
+       }
+
+       @Override
+       public Iterator<Product> getAllProductsIterator () throws ServletException {
+               return this.app.getAllProductsIterator();
+       }
+
+       @Override
+       public Deque<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 {
+       public Deque<Product> getAllProducts () throws ServletException {
                return this.app.getAllProducts();
        }
 
-       /**
-        * Some "getter" for a an array of all categories
-        *
-        * @return All categories
-        */
        @Override
-       public Iterator<Category> getAllCategories () throws ServletException {
+       public Iterator<Category> getAllCategoriesIterator () throws ServletException {
+               return this.app.getAllCategoriesIterator();
+       }
+
+       @Override
+       public Deque<Category> getAllCategories () throws ServletException {
                return this.app.getAllCategories();
        }
 
-       /**
-        * 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);
index 66089c88c7a743bcc878954ad92cdbd7bad04f41..c2475b4c426b5f3f8b458520eb1b6120ebcc610c 100644 (file)
@@ -17,8 +17,6 @@
 package org.mxchange.pizzaapplication.filter.servlet.basket;
 
 import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.sql.SQLException;
 import java.text.MessageFormat;
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
@@ -28,8 +26,6 @@ import javax.servlet.ServletResponse;
 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.CorruptedDatabaseFileException;
 import org.mxchange.jshop.beans.basket.BasketBean;
 import org.mxchange.jshop.item.AddableBasketItem;
 import org.mxchange.pizzaapplication.filter.servlet.BaseServletFilter;
@@ -83,60 +79,55 @@ public class BasketItemAddedFilter extends BaseServletFilter implements Filter {
                // 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())); //NOI18N
 
-               try {
-                       // Cast to servlet request
-                       HttpServletRequest servletRequest = (HttpServletRequest) request;
+               // Cast to servlet request
+               HttpServletRequest servletRequest = (HttpServletRequest) request;
 
-                       // Get session instance
-                       HttpSession session = servletRequest.getSession();
+               // Get session instance
+               HttpSession session = servletRequest.getSession();
 
-                       // Debug message
-                       this.getLogger().debug(MessageFormat.format("session={0}", session)); //NOI18N
+               // Debug message
+               this.getLogger().debug(MessageFormat.format("session={0}", session)); //NOI18N
 
-                       // Should not be null
-                       if (null == session) {
-                               // session is null
-                               throw new NullPointerException("session is null"); //NOI18N
-                       }
+               // Should not be null
+               if (null == session) {
+                       // session is null
+                       throw new NullPointerException("session is null"); //NOI18N
+               }
 
-                       // Get basket instance
-                       BasketBean basket = (BasketBean) session.getAttribute("basket"); //NOI18N
+               // Get basket instance
+               BasketBean basket = (BasketBean) session.getAttribute("basket"); //NOI18N
 
+               // Debug message
+               this.getLogger().debug(MessageFormat.format("basket={0}", basket)); //NOI18N
+
+               // Is the item already added?
+               if (item.getItemId() == null) {
+                       // Item id is not set
+                       throw new NullPointerException(MessageFormat.format("item id of item={0} is null", item)); //NOI18N
+               } else if (item.getItemType() == null) {
+                       // Item type is not set
+                       throw new NullPointerException(MessageFormat.format("item type of item={0} is null", item)); //NOI18N
+               } else if ((item.getAmount() == null) || (item.getAmount() == 0)) {
                        // Debug message
-                       this.getLogger().debug(MessageFormat.format("basket={0}", basket)); //NOI18N
-
-                       // Is the item already added?
-                       if (item.getItemId() == null) {
-                               // Item id is not set
-                               throw new NullPointerException(MessageFormat.format("item id of item={0} is null", item)); //NOI18N
-                       } else if (item.getItemType() == null) {
-                               // Item type is not set
-                               throw new NullPointerException(MessageFormat.format("item type of item={0} is null", item)); //NOI18N
-                       } else if ((item.getAmount() == null) || (item.getAmount() == 0)) {
-                               // Debug message
-                               this.getLogger().debug(MessageFormat.format("Amount for item {0} is null - EXIT!", item)); //NOI18N
-
-                               // Amount is not entered
-                               return;
-                       } else if (basket.isItemAdded(item)) {
-                               // Yes, then throw exception here
-                               throw new ServletException(MessageFormat.format("item id={0} has already been added.", item.getItemId())); //NOI18N
-                       }
-
-                       // Register item with it
-                       basket.addItem(item);
-
-                       // Is amount null or zero?
-                       if ((item.getAmount() == null) || (item.getAmount() == 0)) {
-                               // Then redirect to added=0
-                               ((HttpServletResponse) response).sendRedirect(servletRequest.getContextPath() + "/?add=0"); //NOI18N
-                       } else {
-                               // Redirect to proper URL
-                               ((HttpServletResponse) response).sendRedirect(servletRequest.getContextPath() + "/?add=1"); //NOI18N
-                       }
-               } catch (final SQLException | BadTokenException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
-                       // Continue to throw
-                       throw new ServletException(ex);
+                       this.getLogger().debug(MessageFormat.format("Amount for item {0} is null - EXIT!", item)); //NOI18N
+
+                       // Amount is not entered
+                       return;
+               } else if (basket.isItemAdded(item)) {
+                       // Yes, then throw exception here
+                       throw new ServletException(MessageFormat.format("item id={0} has already been added.", item.getItemId())); //NOI18N
+               }
+
+               // Register item with it
+               basket.addItem(item);
+
+               // Is amount null or zero?
+               if ((item.getAmount() == null) || (item.getAmount() == 0)) {
+                       // Then redirect to added=0
+                       ((HttpServletResponse) response).sendRedirect(servletRequest.getContextPath() + "/?add=0"); //NOI18N
+               } else {
+                       // Redirect to proper URL
+                       ((HttpServletResponse) response).sendRedirect(servletRequest.getContextPath() + "/?add=1"); //NOI18N
                }
 
                // Trace message
index 9cdd3cd24fc9f68cdd5a1ccf7c83c5c9fc914df0..0154ed8e5512b58d509b35ff6164063764e52789 100644 (file)
 package org.mxchange.pizzaapplication.tags.basket;
 
 import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.sql.SQLException;
 import java.text.MessageFormat;
 import javax.servlet.ServletException;
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.tagext.BodyTagSupport;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
-import org.mxchange.jcore.exceptions.BadTokenException;
-import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException;
 import org.mxchange.jshop.beans.basket.BasketBean;
 import org.mxchange.jshop.item.AddableBasketItem;
 import org.mxchange.jshop.product.Product;
@@ -138,7 +134,7 @@ public class MiniBasketTag extends BodyTagSupport implements BasketTag {
                                out.append("  </div>\n"); //NOI18N
                                out.append("</div>\n"); //NOI18N
                        }
-               } catch (final ServletException | IOException | SQLException | BadTokenException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
+               } catch (final ServletException ex) {
                        // Continue to throw
                        throw new JspException(ex);
                }
diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml
new file mode 100644 (file)
index 0000000..eef85cf
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<faces-config version="2.2"
+                         xmlns="http://xmlns.jcp.org/xml/ns/javaee"
+                         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+                         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
+
+</faces-config>
diff --git a/web/WEB-INF/templates/base.tpl b/web/WEB-INF/templates/base.tpl
new file mode 100644 (file)
index 0000000..07d3cf5
--- /dev/null
@@ -0,0 +1,43 @@
+<?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://java.sun.com/jsf/html"
+       xmlns:ui="http://java.sun.com/jsf/facelets">
+
+       <h:head>
+               <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+               <h:outputStylesheet name="./css/default.css"/>
+               <h:outputStylesheet name="./css/cssLayout.css"/>
+               <title>Pizza-Service - <ui:insert name="title">Default title</ui:insert></title>
+       </h:head>
+
+       <h:body>
+               <div id="top">
+                       <ui:insert name="top">
+                               <div id="header"> 
+                                       <div id="title">
+                                               <h1>Pizza-Service - <ui:insert name="title">Default title</ui:insert></h1>
+                                       </div>
+                               </div>
+                       </ui:insert>
+               </div>
+
+               <div id="left_content">
+                       <div id="left">
+                               <ui:insert name="menu">Default menu</ui:insert>
+                       </div>
+
+                       <div id="content" class="left_content">
+                               <ui:insert name="content_header">Default content header</ui:insert>
+                               <ui:insert name="content">Default content</ui:insert>
+                       </div>
+
+                       <div class="clear"></div>
+               </div>
+
+               <div id="footer">
+                       <ui:insert name="footer">Default footer</ui:insert>
+               </div>
+       </h:body>
+</html>
diff --git a/web/WEB-INF/templates/guest/guest_footer.tpl b/web/WEB-INF/templates/guest/guest_footer.tpl
new file mode 100644 (file)
index 0000000..a3c9ec7
--- /dev/null
@@ -0,0 +1,16 @@
+<ui:composition
+       xmlns="http://www.w3.org/1999/xhtml"
+       xmlns:f="http://java.sun.com/jsf/core"
+       xmlns:h="http://java.sun.com/jsf/html"
+       xmlns:ui="http://java.sun.com/jsf/facelets">
+       <div class="footer">
+               <ul class="footer_nav">
+                       <li><a href="${basePath}/">Home</a></li>
+                       <li><a href="${basePath}/imprint.jsp">Impressum</a></li>
+                       <li><a href="${basePath}/terms.jsp">AGBs</a></li>
+                       <li><a href="${basePath}/privacy.jsp">Datenschutz</a></li>
+               </ul>
+       </div>
+
+       <div class="clear"></div>
+</ui:composition>
diff --git a/web/WEB-INF/templates/guest/guest_menu.tpl b/web/WEB-INF/templates/guest/guest_menu.tpl
new file mode 100644 (file)
index 0000000..cf2ebcf
--- /dev/null
@@ -0,0 +1,19 @@
+<ui:composition
+       xmlns="http://www.w3.org/1999/xhtml"
+       xmlns:f="http://java.sun.com/jsf/core"
+       xmlns:h="http://java.sun.com/jsf/html"
+       xmlns:ui="http://java.sun.com/jsf/facelets">
+       <div class="menu">
+               <ul>
+                       <li><a href="${basePath}/" title="Eingangsseite">Home</a></li>
+                       <li><a href="${basePath}/basket.jsp" title="Zum Warenkorb">Zum Warenkorb</a></li>
+                       <li><a href="${basePath}/bye.jsp" title="Sitzung beennden">Sitzung beenden</a></li>
+               </ul>
+
+               <ul>
+                       <li><a href="${basePath}/customer/login.jsp" title="Login für bestehende Kunden">Einloggen</a></li>
+                       <li><a href="${basePath}/customer/register.jsp" title="Anmeldung als neuer Kunde">Neuer Kunde</a></li>
+                       <li><a href="${basePath}/customer/lost_passwd.jsp" title="Neues Passwort erstellen">Passwort vergessen?</a></li>
+               </ul>
+       </div>
+</ui:composition>
index 0851cde8d4cd997db8c679642aaa631b576a3f54..6ddf5b869d3d1ea2aac621c4d4aeebf17feb7490 100644 (file)
@@ -76,7 +76,7 @@
         </session-timeout>
     </session-config>
     <welcome-file-list>
-        <!--<welcome-file>faces/index.xhtml</welcome-file>-->
-        <welcome-file>index.jsp</welcome-file>
+        <welcome-file>faces/index.xhtml</welcome-file>
+        <!--<welcome-file>index.jsp</welcome-file>-->
     </welcome-file-list>
 </web-app>
index 47da4f064c679a05461d168adb57d35503e48625..8aefece39bae808eae1d75992043657419c57fc9 100644 (file)
@@ -63,7 +63,7 @@
                                                </thead>
 
                                                <tbody>
-                                                       <c:forEach var="category" items="${controller.allCategories}">
+                                                       <c:forEach var="category" items="${controller.allCategoriesIterator}">
                                                        <tr>
                                                                <td>
                                                                        ${category.categoryId}:
index 67d48d0ddb4b3abbcba41cc29047f10b5e4e26c8..49af00a141dc0b3ec507fefd39c3bb708321be2f 100644 (file)
@@ -68,7 +68,7 @@
                                                </thead>
 
                                                <tbody>
-                                                       <c:forEach var="product" items="${controller.allProducts}">
+                                                       <c:forEach var="product" items="${controller.allProductsIterator}">
                                                        <tr>
                                                                <td>
                                                                        ${product.itemId}:
index 7d3dbe8154f0e9f45a6f9cdfe54a7f53975f4a9a..ec70c2df286c4f59b72d032ef5fe27b60ee9b76c 100644 (file)
@@ -45,6 +45,7 @@
                        </div>
 
                        <div id="content">
+                               <!-- TODO: Missing in xhtml: //-->
                                <basket:mini_basket basket="${basket}" />
 
                                <table class="table">
@@ -74,7 +75,7 @@
                                        </tbody>
                                </table>
 
-                               <c:forEach var="product" items="${controller.availableProducts}">
+                               <c:forEach var="product" items="${controller.availableProductsIterator}">
                                        <c:choose>
                                                <c:when test="${controller.basket.isAdded(product)}">
                                                        <c:set var="item" value="${controller.basket.item}" />
diff --git a/web/index.xhtml b/web/index.xhtml
new file mode 100644 (file)
index 0000000..958400d
--- /dev/null
@@ -0,0 +1,135 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+         xmlns:h="http://xmlns.jcp.org/jsf/html"
+         xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
+         xmlns:f="http://xmlns.jcp.org/jsf/core"
+         >
+
+       <f:metadata>
+               <f:viewAction action="#{controller.init()}" />
+       </f:metadata>
+
+       <c:set var="basePath" value="#{request.contextPath}" />
+
+       <!--
+       TODO: Not used:
+       xmlns:basket="http://mxchange.org/jshop/tags/basket"
+       //-->
+
+       <ui:composition template="/WEB-INF/templates/base.tpl">
+               <ui:define name="title">Willkommen!</ui:define>
+
+               <ui:define name="menu">
+                       <ui:include id="menu" class="guest_menu" src="/WEB-INF/templates/guest/guest_menu.tpl" />
+               </ui:define>
+
+               <ui:define name="content_header">
+                       Eingangsseite (dummy)
+               </ui:define>
+
+               <ui:define name="content">
+                       <!--
+                       TODO Not used!
+                       <basket:mini_basket basket="#{basket}" />
+
+                       <h:panelGrid class="table" columnClasses="table_data_column" headerClass="table_header_column">
+                               <f:facet name="header">
+                                       Bestellen? Bestellmenge: Produkt: Einzelpreis:
+                               </f:facet>
+                       </h:panelGrid>
+                       //-->
+
+                       <table class="table">
+                               <thead>
+                                       <tr>
+                                               <th colspan="4" class="table_header">
+                                                       Folgendes kann bestellt werden:
+                                               </th>
+                                       </tr>
+                               </thead>
+
+                               <tbody>
+                                       <tr>
+                                               <th class="table_header_column">
+                                                       Bestellen?
+                                               </th>
+                                               <th class="table_header_column">
+                                                       Anzahl:
+                                               </th>
+                                               <th class="table_header_column">
+                                                       Produkt:
+                                               </th>
+                                               <th class="table_header_column">
+                                                       Einzelpreis:
+                                               </th>
+                                       </tr>
+                               </tbody>
+                       </table>
+
+                       <ui:repeat var="product" value="#{controller.availableProducts}">
+                               <c:set var="isAdded" value="#{controller.basket.isAdded(product)}" />
+
+                               <ui:fragment rendered="#{isAdded == true}">
+                                       <table class="table">
+                                               <tbody>
+                                                       <tr>
+                                                               <td class="table_data_column">
+                                                                       <a href="#{basePath}/basket.jsp" title="Zum Warenkorb">Warenkorb</a>
+                                                               </td>
+
+                                                               <td class="table_data_column">
+                                                                       #{controller.basket.item.amount}
+                                                               </td>
+
+                                                               <td class="table_data_column">
+                                                                       #{product.title}
+                                                               </td>
+
+                                                               <td class="table_data_column" align="right">
+                                                                       <h:outputText class="price" value="#{product.price}">
+                                                                               <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" />
+                                                                       </h:outputText>
+                                                               </td>
+                                                       </tr>
+                                               </tbody>
+                                       </table>
+                               </ui:fragment>
+                               <ui:fragment rendered="#{isAdded == false}">
+                                       <h:form acceptcharset="utf-8" id="add_item">
+                                               <table class="table">
+                                                       <tbody>
+                                                               <tr>
+                                                                       <td class="table_data_column">
+                                                                               <h:commandButton class="submit" id="add" value="Hinzufügen" action="#{controller.basket.addToBasket(product)}" />
+                                                                               <h:inputHidden id="itemId" value="#{product.itemId}" />
+                                                                               <h:inputHidden id="itemType" value="Product" />
+                                                                       </td>
+
+                                                                       <td class="table_data_column">
+                                                                               <h:inputText class="input" id="amount" size="3" maxlength="20" />
+                                                                       </td>
+
+                                                                       <td class="table_data_column">
+                                                                               #{product.title}
+                                                                       </td>
+
+                                                                       <td class="table_data_column" align="right">
+                                                                               <h:outputText class="price" value="#{product.price}">
+                                                                                       <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" />
+                                                                               </h:outputText>
+                                                                       </td>
+                                                               </tr>
+                                                       </tbody>
+                                               </table>
+                                       </h:form>
+                               </ui:fragment>
+                       </ui:repeat>
+               </ui:define>
+
+               <ui:define name="footer">
+                       <ui:include id="footer" class="guest_footer" src="/WEB-INF/templates/guest/guest_footer.tpl" />
+               </ui:define>
+       </ui:composition>
+</html>
diff --git a/web/resources/css/cssLayout.css b/web/resources/css/cssLayout.css
new file mode 100644 (file)
index 0000000..3d3b2cb
--- /dev/null
@@ -0,0 +1,136 @@
+#top {
+       position: relative;
+       background-color: #036fab;
+       color: white;
+       padding: 5px;
+       margin: 0px 0px 10px 0px;
+}
+
+#footer {
+       position: relative;
+       background-color: #c2dfef;
+       padding: 5px;
+       margin: 10px 0px 0px 0px;
+}
+
+#left {
+       float: left;
+       background-color: #ece3a5;
+       padding: 5px;
+       width: 150px;
+}
+
+#right {
+       float: right;
+       background-color: #ece3a5;
+       padding: 5px;
+       width: 150px;
+}
+
+.center_content {
+       position: relative;
+       background-color: #dddddd;
+       padding: 5px;
+}
+
+.left_content {
+       background-color: #dddddd;
+       padding: 5px;
+       margin-left: 170px;
+}
+
+.right_content {
+       background-color: #dddddd;
+       padding: 5px;
+       margin: 0px 170px 0px 170px;
+}
+
+#top a:link, #top a:visited {
+       color: white;
+       font-weight : bold;
+       text-decoration: none;
+}
+
+#top a:link:hover, #top a:visited:hover  {
+       color: black;
+       font-weight : bold;
+       text-decoration : underline;
+}
+
+/**
+div {
+       border: 1px solid #ff0000;
+}
+/**/
+
+table, .table {
+       margin: 0px;
+       padding: 0px;
+}
+
+.table {
+       width: 500px;
+}
+
+.table_row {
+       width: 100%;
+}
+
+.table_left {
+       width: 250px;
+       float: left;
+}
+
+.table_right {
+       width: 200px;
+       float: right;
+}
+
+.table_left25 {
+       width: 20px;
+       float: left;
+}
+
+.table_right75 {
+       width: 430px;
+       float: right;
+}
+
+.para {
+       padding: 5px 5px 5px 5px;
+}
+
+.clear {
+       clear: both;
+}
+
+ul.footer_nav {
+       text-align: center;
+       width : 500px;
+       list-style: none;
+       margin: 0px;
+}
+
+ul.footer_nav li {
+       float: left;
+       width: 100px;
+}
+
+.menu ul {
+       list-style: none;
+       padding-left: 5px;
+}
+
+.table_header {
+       text-align: center;
+       font-weight: bold;
+       font-size: 20px;
+}
+
+.table_header_column {
+       width: 100px;
+}
+
+.table_data_column {
+       width: 100px;
+}
diff --git a/web/resources/css/default.css b/web/resources/css/default.css
new file mode 100644 (file)
index 0000000..c658b11
--- /dev/null
@@ -0,0 +1,28 @@
+body {
+       background-color: #ffffff;
+       font-size: 12px;
+       font-family: lucida;
+       color: #000000;  
+       margin: 10px;
+}
+
+h1 {
+       border-bottom: 1px solid #AFAFAF; 
+       font-size:  16px;
+       font-weight: bold;
+       margin: 0px;
+       padding: 0px;
+       color: #D20005;
+}
+
+a:link, a:visited {
+       color: #045491;
+       font-weight : bold;
+       text-decoration: none;
+}
+
+a:link:hover, a:visited:hover  {
+       color: #045491;
+       font-weight : bold;
+       text-decoration : underline;
+}
index 920de9f4d7faaa507872c152087c44452314e165..e1d2becea5dfb122f159ceed1f556824a43ee9b8 100644 (file)
@@ -10,7 +10,7 @@
 <jsp:useBean id="controller" scope="session" class="org.mxchange.pizzaapplication.beans.controller.PizzaServiceBean" type="PizzaBean" />
 
 <select class="select" name="categoryId" size="1">
-       <c:forEach var="category" items="${controller.allCategories}">
+       <c:forEach var="category" items="${controller.allCategoriesIterator}">
                <option value="${category.categoryId}">${category.decodedTitle}</option>
        </c:forEach>
 </select>
index eb98e8defe4e556c536d06095b39bb1bce723e74..c00a925e539645b41bd430cdd23dc6fc188a561d 100644 (file)
@@ -11,7 +11,7 @@
 
 <select class="select" name="parentId" size="1">
        <option value="">Ist oberste Kategorie</option>
-       <c:forEach var="category" items="${controller.allCategories}">
+       <c:forEach var="category" items="${controller.allCategoriesIterator}">
                <option value="${category.categoryId}">${category.decodedTitle}</option>
        </c:forEach>
 </select>