]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Continued with project:
authorRoland Haeder <roland@mxchange.org>
Tue, 18 Aug 2015 04:59:47 +0000 (06:59 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 18 Aug 2015 04:59:47 +0000 (06:59 +0200)
- started to rewrite to a more flexible solution: a general item basket that will accept OrderableItem instances
- added parameter "type" for upcoming basket feature
- renamed "choose" to "id", this old thing will be completely rewritten
- added new script "add_item.jsp"
- added some more CSS for footer navigation
- Accessing the JSPs directly may not be a good idea, better is to have aliases (more about that later)
- added generic interface OrderableItem and BasketItem class (unfinished)
- added links in footer.jsp for new pages "privacy.jsp", "terms.jsp" and "imprint.jsp"
- using JSTL "fmt" for formatting currency values
- added project's license "GPL3"
Signed-off-by:Roland Häder <roland@mxchange.org>

13 files changed:
nbproject/project.properties
src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java
src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java
src/java/org/mxchange/pizzaapplication/item/BaseItem.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/item/OrderableItem.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/item/basket/BasketItem.java [new file with mode: 0644]
web/form_handler/add_item.jsp [new file with mode: 0644]
web/imprint.jsp [new file with mode: 0644]
web/index.jsp
web/static/admin/menu.jsp
web/static/footer.jsp
web/static/menu.jsp
web/style.css

index 08ca929fc0f640b0cd9d42d38d4a81684fedbc3b..b7f8833cdc9321c1dec79ce4908b1be67ec7cb9a 100644 (file)
@@ -78,6 +78,7 @@ javadoc.windowtitle=
 lib.dir=${web.docbase.dir}/WEB-INF/lib
 persistence.xml.dir=${conf.dir}
 platform.active=default_platform
+project.license=gpl30
 resource.dir=setup
 run.test.classpath=\
     ${javac.test.classpath}:\
index c7545bef5c2c12450a18f283e1e2ec21f1205353..a1879ee4899fd30fcc740f5ffd11d860d23a681b 100644 (file)
@@ -38,9 +38,14 @@ public interface PizzaApplication extends Application {
        public static final String HTTP_PARAM_AMOUNT = "amount"; //NOI18N
 
        /**
-        * HTTP parameter "choose"
+        * HTTP parameter "id"
         */
-       public static final String HTTP_PARAM_CHOOSE = "choose"; //NOI18N
+       public static final String HTTP_PARAM_ITEM_ID = "id"; //NOI18N
+
+       /**
+        * HTTP parameter "type"
+        */
+       public static final String HTTP_PARAM_ITEM_TYPE = "type"; //NOI18N
 
        /**
         * Session key "ordered"
@@ -49,8 +54,10 @@ public interface PizzaApplication extends Application {
 
        /**
         * Mask for all parameters
+        * @deprecated Please refacture!
         */
-       public static final String HTTP_PARAM_MASK = "%s[%s]"; //NOI18N
+       @Deprecated
+       static final String HTTP_PARAM_MASK = "%s[%s]"; //NOI18N
 
        /**
         * Some "getter" for amount from session
index c271602c1884c0a85808f7df3cdd8566f2802c70..d94e23b3b6f29f155eeab7c55480b1ceaea6666d 100644 (file)
@@ -366,7 +366,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                }
 
                // Get attribute
-               Object object = this.getValueFromSession(product, session, HTTP_PARAM_CHOOSE);
+               Object object = this.getValueFromSession(product, session, HTTP_PARAM_ITEM_ID);
 
                // Is the object null?
                if (object == null) {
@@ -839,7 +839,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
 
                // Mark it as ordered by setting flag
                this.getLogger().debug(MessageFormat.format("Marking product={0} as choosen.", product.getId())); //NOI18N
-               this.setValueInSession(product, session, HTTP_PARAM_CHOOSE, "1"); //NOI18N
+               this.setValueInSession(product, session, HTTP_PARAM_ITEM_ID, "1"); //NOI18N
 
                // Trace message
                this.getLogger().trace("EXIT!"); //NOI18N
@@ -916,7 +916,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
 
                // Mark it as ordered by setting flag
                this.getLogger().debug(MessageFormat.format("Unmarking product={0} as choosen.", product.getId())); //NOI18N
-               this.clearSessionAttribute(product, session, HTTP_PARAM_CHOOSE);
+               this.clearSessionAttribute(product, session, HTTP_PARAM_ITEM_ID);
 
                // Trace message
                this.getLogger().trace("EXIT!"); //NOI18N
@@ -1062,14 +1062,14 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                }
 
                // Get reqzest element
-               object = request.getParameter(String.format(HTTP_PARAM_MASK, HTTP_PARAM_CHOOSE, product.getId()));
+               object = request.getParameter(String.format(HTTP_PARAM_MASK, HTTP_PARAM_ITEM_ID, product.getId()));
                this.getLogger().debug(MessageFormat.format("product={0},object={1}", product.getId(), object)); //NOI18N
 
                // Is it null?
                if (object == null) {
                        // Unset session
                        this.getLogger().debug(MessageFormat.format("Unsetting session for product={0} ...", product.getId())); //NOI18N
-                       this.clearSessionAttribute(product, session, HTTP_PARAM_CHOOSE);
+                       this.clearSessionAttribute(product, session, HTTP_PARAM_ITEM_ID);
                        this.clearSessionAttribute(product, session, HTTP_PARAM_AMOUNT);
 
                        // Return empty string
@@ -1077,7 +1077,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                }
 
                // Then set it in session
-               this.setValueInSession(product, session, HTTP_PARAM_CHOOSE, object);
+               this.setValueInSession(product, session, HTTP_PARAM_ITEM_ID, object);
 
                // Cast to string and return it
                this.getLogger().debug(MessageFormat.format("product={0} - Returning {1} ...", product.getId(), object)); //NOI18N
diff --git a/src/java/org/mxchange/pizzaapplication/item/BaseItem.java b/src/java/org/mxchange/pizzaapplication/item/BaseItem.java
new file mode 100644 (file)
index 0000000..262ed53
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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.item;
+
+import org.mxchange.jcore.BaseFrameworkSystem;
+
+/**
+ * A general item cl
+ * @author Roland Haeder
+ */
+public class BaseItem extends BaseFrameworkSystem implements OrderableItem {
+       /**
+        * Item id number
+        */
+       private Long id;
+
+       /**
+        * Item type
+        */
+       private String type;
+
+       /**
+        * @return the id
+        */
+       public final Long getId () {
+               return this.id;
+       }
+
+       /**
+        * @param id the id to set
+        */
+       public final void setId (final Long id) {
+               this.id = id;
+       }
+
+       /**
+        * @return the type
+        */
+       public final String getType () {
+               return this.type;
+       }
+
+       /**
+        * @param type the type to set
+        */
+       public final void setType (final String type) {
+               this.type = type;
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/item/OrderableItem.java b/src/java/org/mxchange/pizzaapplication/item/OrderableItem.java
new file mode 100644 (file)
index 0000000..871e2eb
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.item;
+
+import org.mxchange.jcore.FrameworkInterface;
+
+/**
+ *
+* @author Roland Haeder
+  */
+public interface OrderableItem extends FrameworkInterface {
+}
diff --git a/src/java/org/mxchange/pizzaapplication/item/basket/BasketItem.java b/src/java/org/mxchange/pizzaapplication/item/basket/BasketItem.java
new file mode 100644 (file)
index 0000000..ae149e9
--- /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.item.basket;
+
+import org.mxchange.pizzaapplication.item.BaseItem;
+
+/**
+ * A basket item for Pizza service
+ *
+ * @author Roland Haeder
+ */
+public class BasketItem extends BaseItem {
+}
diff --git a/web/form_handler/add_item.jsp b/web/form_handler/add_item.jsp
new file mode 100644 (file)
index 0000000..7d9f761
--- /dev/null
@@ -0,0 +1,47 @@
+<%-- 
+       Document   : add_item
+       Ceated on : Aug 17, 2015, 7:03:38 PM
+       Author     : Roland Haeder
+--%>
+
+<%@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.item.OrderableItem"%>
+
+<%
+       // Init application instance
+       PizzaApplication app = PizzaServiceApplication.getInstance(application);
+
+       // Redirect to proper URL
+       // @TODO Commented out for debugging
+       //response.sendRedirect(request.getContextPath() + "/?add=1");
+%>
+<jsp:forward page="../index.jsp" />
+
+<!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%> - Form-Handler</title>
+       </head>
+
+       <body>
+               <div id="title">
+                       <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Form-Handler</h1>
+               </div>
+
+               <jsp:include page="/static/admin/menu.jsp" flush="true" />
+
+               <div id="content_outer">
+                       <div id="content_title">
+                               <h2>Bitte nicht direkt aufrufen:</h2>
+                       </div>
+
+                       <div id="content">
+                               Bitte rufen Sie diese Seite nicht direkt auf.
+                       </div>
+               </div>
+       </body>
+</html>
diff --git a/web/imprint.jsp b/web/imprint.jsp
new file mode 100644 (file)
index 0000000..7631c91
--- /dev/null
@@ -0,0 +1,38 @@
+<%-- 
+       Document   : login
+       Created on : 11.08.2015, 11:35:53
+       Author     : Roland Haeder
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
+       <head>
+               <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+               <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
+               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Impressum</title>
+       </head>
+
+       <body>
+               <div id="header"> 
+                       <div id="title">
+                               <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Impressum</h1>
+                       </div>
+               </div>
+
+               <jsp:include page="/static/menu.jsp" flush="true" />
+
+               <div id="content_outer">
+                       <div id="content_title">
+                               <h2>Impressum:</h2>
+                       </div>
+
+                       <div id="content">
+                       </div>
+               </div>
+
+               <jsp:include page="/static/footer.jsp" flush="true" />
+       </body>
+</html>
index 0da8453c48280decf6dfe25e6091ac140b9f4a46..ae7eb48335071993245cf6b03504954a5971a87a 100644 (file)
@@ -11,6 +11,7 @@
 <%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
 <%@page import="org.mxchange.pizzaapplication.product.Product"%>
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
 
 <%
        // Init application instance
        <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%> - Eingangsseite</title>
+               <title><%=PizzaServiceApplication.MAIN_TITLE%> - Willkommen</title>
        </head>
 
        <body>
                <div id="header"> 
                        <div id="title">
-                               <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Eingangsseite</h1>
+                               <h1><%=PizzaServiceApplication.MAIN_TITLE%> - Willkommen</h1>
                        </div>
                </div>
 
@@ -39,7 +40,6 @@
                        </div>
 
                        <div id="content">
-                               <form action="<%=request.getContextPath()%>/form_handler/do_preview.jsp" accept-charset="utf-8" id="form" method="post">
                                <table class="table">
                                        <thead>
                                                <tr>
                                                        app.unmarkProductAsOrdered(product, session);
                                                        %>
                                                        <tr>
+                                                               <form action="<%=request.getContextPath()%>/form_handler/add_item.jsp" accept-charset="utf-8" id="form" method="post">
                                                                <td>
-                                                                       <input class="input" type="checkbox" name="<%=String.format(PizzaApplication.HTTP_PARAM_MASK, PizzaApplication.HTTP_PARAM_CHOOSE, product.getId())%>" value="1" <%=app.getCheckedHtmlFromProduct(product, request, session)%> />
+                                                                       <input class="submit" type="submit" name="add" value="Hinzuf&uuml;gen" />
+                                                                       <input class="input" type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_ID%>" value="<%=product.getId()%>" />
+                                                                       <input class="input" type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_TYPE%>" value="<%=Product.class%>" />
                                                                </td>
                                                                <td>
-                                                                       <input class="input" type="text" name="<%=String.format(PizzaApplication.HTTP_PARAM_MASK, PizzaApplication.HTTP_PARAM_AMOUNT, product.getId())%>" value="<%=app.getAmountFromSession(product, session)%>" size="3" maxlength="20" />
+                                                                       <input class="input" type="text" name="<%=PizzaApplication.HTTP_PARAM_AMOUNT%>" size="3" maxlength="20" />
                                                                </td>
                                                                <td>
                                                                        <%=product.getTitle()%>
                                                                        <fmt:formatNumber type="currency"><%=product.getPrice()%></fmt:formatNumber>
                                                                </td>
                                                        </tr>
+                                                       </form>
                                                        <%
                                                }
                                                %>
-
-                                               <tr>
-                                                       <td colspan="4" class="table_footer">
-                                                               <input class="reset" type="reset" value="Formular zurücksetzen" />
-                                                               <input class="submit" type="submit" name="send" value="Bestellung ansehen" />
-                                                       </td>
-                                               </tr>
                                        </tbody>
                                </table>
-                               </form>
                        </div>
                </div>
 
index 627ffde63c5c781df29e4bee098fed1ca7f585f9..2f574f437a7cc8131fcb6a1cc2d704cf7deddf77 100644 (file)
@@ -6,7 +6,7 @@
 
 <div id="menu">
        <ul>
-               <li><a href="<%=request.getContextPath()%>/admin/index.jsp" title="Eingangsseite">Home</a></li>
+               <li><a href="<%=request.getContextPath()%>/admin/" title="Eingangsseite">Home</a></li>
                <li><a href="<%=request.getContextPath()%>/admin/category.jsp" title="Kazegorie">Kategorie</a></li>
                <li><a href="<%=request.getContextPath()%>/admin/product.jsp" title="Produkt">Produkt</a></li>
        </ul>
index 306b486792b99f3e16cc3a2295afa3186b48a0e3..cf0e536d76a54c86fa225a8590a859efd7811e96 100644 (file)
@@ -5,6 +5,10 @@
 --%>
 <div class="footer">
        <ul class="footer_nav">
-               <li>
+               <li><a href="<%=request.getContextPath()%>/">Home</a></li>
+               <li><a href="<%=request.getContextPath()%>/imprint.jsp">Impressum</a></li>
+               <li><a href="<%=request.getContextPath()%>/terms.jsp">AGBs</a></li>
+               <li><a href="<%=request.getContextPath()%>/privacy.jsp">Datenschutz</a></li>
        </ul>
 </div>
+<div class="clear"></div>
index 7838c2ee9fa1c86d6375aa55e47fe210ef8d5c8f..d5b6493e15bca87e33fda0212e3490d87b5aeee8 100644 (file)
@@ -6,7 +6,7 @@
 
 <div id="menu">
        <ul>
-               <li><a href="<%=request.getContextPath()%>/index.jsp" title="Eingangsseite">Home</a></li>
+               <li><a href="<%=request.getContextPath()%>/" title="Eingangsseite">Home</a></li>
                <li><a href="<%=request.getContextPath()%>/preview.jsp" title="Bestellseite">Bestellung</a></li>
                <li><a href="<%=request.getContextPath()%>/finished.jsp" title="Bestellung abgeschlossen">Vielen Dank</a></li>
                <li><a href="<%=request.getContextPath()%>/bye.jsp" title="Sitzung beennden">Sitzung beenden</a></li>
index 7dd8fbdd4595adb1e0c557ca1b7d90f0178e982c..ca487498cdae13b4f7277818e9742c3952ff436f 100644 (file)
@@ -44,3 +44,19 @@ table, .table {
 .clear {
        clear: both;
 }
+
+ul.footer_nav {
+       text-align: center;
+       width   : 500px;
+       list-style: none;
+}
+
+ul.footer_nav li {
+       float: left;
+       width: 100px;
+}
+
+#menu ul {
+       list-style: none;
+       padding-left: 5px;
+}