From e51a9407d63e9330c47aba69945352ff599d8840 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 18 Aug 2015 06:59:47 +0200 Subject: [PATCH] =?utf8?q?Continued=20with=20project:=20-=20started=20to?= =?utf8?q?=20rewrite=20to=20a=20more=20flexible=20solution:=20a=20general?= =?utf8?q?=20item=20basket=20that=20will=20accept=20OrderableItem=20instan?= =?utf8?q?ces=20-=20added=20parameter=20"type"=20for=20upcoming=20basket?= =?utf8?q?=20feature=20-=20renamed=20"choose"=20to=20"id",=20this=20old=20?= =?utf8?q?thing=20will=20be=20completely=20rewritten=20-=20added=20new=20s?= =?utf8?q?cript=20"add=5Fitem.jsp"=20-=20added=20some=20more=20CSS=20for?= =?utf8?q?=20footer=20navigation=20-=20Accessing=20the=20JSPs=20directly?= =?utf8?q?=20may=20not=20be=20a=20good=20idea,=20better=20is=20to=20have?= =?utf8?q?=20aliases=20(more=20about=20that=20later)=20-=20added=20generic?= =?utf8?q?=20interface=20OrderableItem=20and=20BasketItem=20class=20(unfin?= =?utf8?q?ished)=20-=20added=20links=20in=20footer.jsp=20for=20new=20pages?= =?utf8?q?=20"privacy.jsp",=20"terms.jsp"=20and=20"imprint.jsp"=20-=20usin?= =?utf8?q?g=20JSTL=20"fmt"=20for=20formatting=20currency=20values=20-=20ad?= =?utf8?q?ded=20project's=20license=20"GPL3"=20Signed-off-by:Roland=20H?= =?utf8?q?=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- nbproject/project.properties | 1 + .../application/PizzaApplication.java | 13 +++- .../application/PizzaServiceApplication.java | 12 ++-- .../pizzaapplication/item/BaseItem.java | 63 +++++++++++++++++++ .../pizzaapplication/item/OrderableItem.java | 26 ++++++++ .../item/basket/BasketItem.java | 27 ++++++++ web/form_handler/add_item.jsp | 47 ++++++++++++++ web/imprint.jsp | 38 +++++++++++ web/index.jsp | 22 +++---- web/static/admin/menu.jsp | 2 +- web/static/footer.jsp | 6 +- web/static/menu.jsp | 2 +- web/style.css | 16 +++++ 13 files changed, 250 insertions(+), 25 deletions(-) create mode 100644 src/java/org/mxchange/pizzaapplication/item/BaseItem.java create mode 100644 src/java/org/mxchange/pizzaapplication/item/OrderableItem.java create mode 100644 src/java/org/mxchange/pizzaapplication/item/basket/BasketItem.java create mode 100644 web/form_handler/add_item.jsp create mode 100644 web/imprint.jsp diff --git a/nbproject/project.properties b/nbproject/project.properties index 08ca929f..b7f8833c 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -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}:\ diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java index c7545bef..a1879ee4 100644 --- a/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java +++ b/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java @@ -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 diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java index c271602c..d94e23b3 100644 --- a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java +++ b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java @@ -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 index 00000000..262ed53a --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/item/BaseItem.java @@ -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 . + */ +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 index 00000000..871e2eb0 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/item/OrderableItem.java @@ -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 . + */ +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 index 00000000..ae149e9f --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/item/basket/BasketItem.java @@ -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 . + */ +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 index 00000000..7d9f761a --- /dev/null +++ b/web/form_handler/add_item.jsp @@ -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"); +%> + + + + + + + + <%=PizzaServiceApplication.MAIN_TITLE%> - Form-Handler + + + +
+

<%=PizzaServiceApplication.MAIN_TITLE%> - Form-Handler

+
+ + + +
+
+

Bitte nicht direkt aufrufen:

+
+ +
+ Bitte rufen Sie diese Seite nicht direkt auf. +
+
+ + diff --git a/web/imprint.jsp b/web/imprint.jsp new file mode 100644 index 00000000..7631c911 --- /dev/null +++ b/web/imprint.jsp @@ -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"%> + + + + + + + <%=PizzaServiceApplication.MAIN_TITLE%> - Impressum + + + + + + + +
+
+

Impressum:

+
+ +
+
+
+ + + + diff --git a/web/index.jsp b/web/index.jsp index 0da8453c..ae7eb483 100644 --- a/web/index.jsp +++ b/web/index.jsp @@ -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 @@ -21,13 +22,13 @@ - <%=PizzaServiceApplication.MAIN_TITLE%> - Eingangsseite + <%=PizzaServiceApplication.MAIN_TITLE%> - Willkommen @@ -39,7 +40,6 @@
-
@@ -72,11 +72,14 @@ app.unmarkProductAsOrdered(product, session); %> + + <% } %> - - - -
- /> + + + - + <%=product.getTitle()%> @@ -85,19 +88,12 @@ <%=product.getPrice()%>
-
diff --git a/web/static/admin/menu.jsp b/web/static/admin/menu.jsp index 627ffde6..2f574f43 100644 --- a/web/static/admin/menu.jsp +++ b/web/static/admin/menu.jsp @@ -6,7 +6,7 @@