- 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>
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}:\
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"
/**
* 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
}
// 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) {
// 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
// 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
}
// 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
}
// 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
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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 {
+}
--- /dev/null
+/*
+ * 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 {
+}
--- /dev/null
+<%--
+ 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>
--- /dev/null
+<%--
+ 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>
<%@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>
</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ü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>
<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>
--%>
<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>
<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>
.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;
+}