* @return Human-readable version of product availability
*/
public String getPrintableProduktAvailability (final Product product);
+
+ /**
+ * Marks all choosen products as ordered
+ *
+ * @param request Request instance
+ * @param session Session instance
+ * @throws javax.servlet.ServletException If something unexpected happened
+ */
+ public void markAllChoosenProductsAsOrdered (final HttpServletRequest request, final HttpSession session) throws ServletException;
}
import org.mxchange.pizzaapplication.product.Product;
/**
+ * Main application class
*
* @author Roland Haeder
*/
return (!amount.isEmpty() && !"0".equals(amount)); //NOI18N
}
+ /**
+ * Marks all choosen products as ordered
+ *
+ * @param request Request instance
+ * @param session Session instance
+ */
+ @Override
+ public void markAllChoosenProductsAsOrdered (final HttpServletRequest request, final HttpSession session) throws ServletException {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("request={0},session={1} - CALLED!", request, session));
+
+ // Init iterator
+ Iterator<Product> iterator;
+
+ try {
+ // Get iterator
+ iterator = this.getProducts();
+ } catch (final IOException | BadTokenException ex) {
+ throw new ServletException(ex);
+ }
+
+ // "Walk" over all products
+ while (iterator.hasNext()) {
+ // Get next product
+ Product product = iterator.next();
+
+ // Debug message
+ this.getLogger().debug(MessageFormat.format("product={0}", product));
+
+ // Is it choosen?
+ if (this.isProductChoosen(product, request, session)) {
+ // Mark product as ordered
+ this.markProductAsOrdered(product, session);
+ }
+ }
+
+ // Trace message
+ this.getLogger().trace("EXIT!");
+ }
+
/**
* Marks given product as choosen in session
*
Author : Roland Haeder
--%>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--<%@page errorPage="errorHandler.jsp" %>--%>
<%@page import="org.mxchange.pizzaapplication.category.Category"%>
<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
</thead>
<tbody class="table_body">
- <%
- // "Walk" through all products and unmark them as ordered
- for (final Category category : app.getCategories()) {
- %>
- <tr>
- <td>
- <%=category.getId()%>
- </td>
- <td>
- <%=category.getTitle()%>
- </td>
- <td>
- <%=category.getPrice()%>
- </td>
- </tr>
- <%
- }
- %>
+ <c:forEach var="category" items="<%=app.getCategories()%>">
+ <tr>
+ <td>
+ ${category.getId()}
+ </td>
+ <td>
+ ${category.getTitle()}
+ </td>
+ <td>
+ ${category.getPrice()}
+ </td>
+ </tr>
+ </c:forEach>
<tr>
<td colspan="3" class="table_footer">
Author : Roland Haeder
--%>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--<%@page errorPage="errorHandler.jsp" %>--%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Map"%>
</thead>
<tbody class="table_body">
- <%
- // "Walk" through all products and unmark them as ordered
- for (final Product product : app.getProducts()) {
- %>
- <tr>
- <td>
- <%=product.getId()%>
- </td>
- <td>
- <%=product.getTitle()%>
- </td>
- <td>
- <%=product.getPrice()%>
- </td>
- <td>
- <%=app.getPrintableProduktAvailability(product)%>
- </td>
- </tr>
- <%
- }
- %>
-
+ <c:forEach var="product" items="<%=app.getProducts()%>">
+ <tr>
+ <td>
+ ${product.getId()}
+ </td>
+ <td>
+ ${product.getTitle()}
+ </td>
+ <td>
+ ${product.getPrice()}
+ </td>
+ <td>
+ ${app.getPrintableProduktAvailability(product)}
+ </td>
+ </tr>
+ </c:forEach>
<tr>
<td colspan="4" class="table_footer">
<input type="reset" value="Formular zurücksetzen" />
// Is it post?
if ("POST".equals(request.getMethod())) { //NOI18N
- // Handle saving customer data and such things
+ // @TODO Handle saving customer data and such things
+
+ // Mark all choosen products as ordered
+ app.markAllChoosenProductsAsOrdered(request, session);
// Redirect to proper URL
// @TODO Commented out for developing: