}
// Get element
- this.getLogger().debug("Calling handleChooseFromRequestSession() ..."); //NOI18N
+ this.getLogger().debug(MessageFormat.format("Calling handleChooseFromRequestSession({0},{1},{2}) ...", product.getName(), request, session)); //NOI18N
String choosen = this.handleChooseFromRequestSession(product, request, session);
this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getName(), choosen)); //NOI18N
}
// Get choosen
- this.getLogger().debug("Calling handleChooseFromRequestSession() ..."); //NOI18N
+ this.getLogger().debug(MessageFormat.format("Calling handleChooseFromRequestSession({0},{1},{2}) ...", product.getName(), request, session)); //NOI18N
String choosen = this.handleChooseFromRequestSession(product, request, session);
this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getName(), choosen)); //NOI18N
this.getLogger().warn(ex);
return "0"; //NOI18N
}
-
+
// Then set it in session
this.setValueInSession(product, session, HTTP_PARAM_AMOUNT, object);
-
+
// And return it
return (String) object;
}
-
+
// Trace message
this.getLogger().trace("Calling getAmountFromSession() ..."); //NOI18N
// Not set
throw new NullPointerException("session is null"); //NOI18N
}
-
+
// Get choosen
- this.getLogger().debug("Calling handleChooseFromRequestSession() ..."); //NOI18N
+ this.getLogger().debug(MessageFormat.format("Calling handleChooseFromRequestSession({0},{1},{2}) ...", product.getName(), request, session)); //NOI18N
String choosen = this.handleChooseFromRequestSession(product, request, session);
this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getName(), choosen)); //NOI18N
-
+
// Must not be null
assert(choosen instanceof String): "choosen is null"; //NOI18N
-
+
// Is it not choosen?
if (choosen.isEmpty()) {
// Not choosen
// Get amount
String amount = this.handleAmountFromRequestSession(product, request, session);
-
+
// Must not be null
assert(amount instanceof String): "amount is not set"; //NOI18N
-
+
// Trace message
this.getLogger().trace(MessageFormat.format("amount={0} - EXIT!", amount)); //NOI18N
this.getLogger().trace(MessageFormat.format("product={0},session={1},attribute={2} - CALLED!", product, session, attribute)); //NOI18N
// Init variable
- Object value = this.getValueFromSession(session, String.format(HTTP_PARAM_MASK, product.getName(), attribute));
+ Object value = this.getValueFromSession(session, String.format(HTTP_PARAM_MASK, attribute, product.getName()));
this.getLogger().debug(MessageFormat.format("product={0},attribute={1},value={2}", product.getName(), attribute, value)); //NOI18N
*/
private Object getValueFromSession (final HttpSession session, final String key) {
// Trace message
- this.getLogger().trace(MessageFormat.format("session={043},key={1} - CALLED!", session, key)); //NOI18N
+ this.getLogger().trace(MessageFormat.format("session={0},key={1} - CALLED!", session, key)); //NOI18N
// Init value
Object value = null;
// Check request method
if (!"POST".equals(request.getMethod())) { //NOI18N
// Not POST, so get from session
+ this.getLogger().trace(MessageFormat.format("Calling this.getChooseFromSession({0},{1}) ... - EXIT!", product.getName(), session));
return this.getChooseFromSession(product, session);
} else if (this.isProductOrdered(product, session)) {
// Product is ordered
+ this.getLogger().trace(MessageFormat.format("Calling this.getChooseFromSession({0},{1}) ... - EXIT!", product.getName(), session));
+ return this.getChooseFromSession(product, session);
+ } else if (!this.getChooseFromSession(product, session).isEmpty()) {
+ // Found in session
+ this.getLogger().trace(MessageFormat.format("Calling this.getChooseFromSession({0},{1}) ... - EXIT!", product.getName(), session));
return this.getChooseFromSession(product, session);
}
-
+
// Get reqzest element
object = request.getParameter(String.format(HTTP_PARAM_MASK, HTTP_PARAM_CHOOSE, product.getName()));
this.getLogger().debug(MessageFormat.format("product={0},object={1}", product.getName(), object)); //NOI18N
private void setValueInSession (final Product product, final HttpSession session, final String keyPart, final Object value) {
// Trace message
this.getLogger().trace(MessageFormat.format("product={0},session={1},keyPart={2},value={3} - CALLED!", product, session, keyPart, value)); //NOI18N
-
- synchronized(session) {
- // Set it synced
- this.getLogger().debug(MessageFormat.format("Setting value={0} for product={1},keyPart={2}", value, product.getName(), keyPart)); //NOI18N
- this.setValueInSession(session, String.format(HTTP_PARAM_MASK, product.getName(), keyPart), value);
- }
-
+
+ // Set it synced
+ this.getLogger().debug(MessageFormat.format("Setting value={0} for product={1},keyPart={2}", value, product.getName(), keyPart)); //NOI18N
+ this.setValueInSession(session, String.format(HTTP_PARAM_MASK, keyPart, product.getName()), value);
+
// Trace message
this.getLogger().trace("EXIT!"); //NOI18N
}
<%--<%@page errorPage="errorHandler.jsp" %>--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
-<%@page import="org.mxchange.pizzaapplication.beans.CustomerBean" %>
<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
+<%@page import="org.mxchange.pizzaapplication.beans.CustomerBean" %>
+<%@page import="org.mxchange.pizzaapplication.product.Product"%>
<%
// Init application instance
// Is it post?
if ("POST".equals(request.getMethod())) { //NOI18N
// Handle saving customer data and such things
+
+ // "Walk" over all products
+ for (final Product product : app.getProducts()) {
+ // Is it choosen?
+ if (app.isProductChoosen(product, request, session)) {
+ // Mark product as ordered
+ app.markProductAsOrdered(product, session);
+ }
+ }
+
// Redirect to proper URL
// @TODO Commented out for developing:
//response.sendRedirect(request.getContextPath() + "/finished.jsp");