From: Roland Haeder Date: Tue, 18 Aug 2015 04:59:47 +0000 (+0200) Subject: Continued with project: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e51a9407d63e9330c47aba69945352ff599d8840;p=pizzaservice-war.git Continued with project: - 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 --- 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 @@