*/
public void markProductAsOrdered(final Product product, final HttpSession session);
+ /**
+ * Marks given product as choosen in session
+ *
+ * @param product Product to mark as ordered
+ * @param session Session instance
+ */
+ public void markProductAsChoosen(final Product product, final HttpSession session);
+
/**
* Unmarks given product as ordered in session
*
public Product[] getProducts () {
return (Product[]) this.products.values().toArray();
}
+
+ /**
+ * Marks given product as choosen in session
+ *
+ * @param product Product to mark as ordered
+ * @param session Session instance
+ */
+ @Override
+ public void markProductAsChoosen(final Product product, final HttpSession session) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("product={0},session={1} - CALLED!", product, session)); //NOI18N
+
+ // Is product and session set?
+ if (product == null) {
+ // Not set
+ throw new NullPointerException("product is null"); //NOI18N
+ } else if (session == null) {
+ // Not set
+ throw new NullPointerException("session is null"); //NOI18N
+ }
+
+ // Mark it as ordered by setting flag
+ this.getLogger().debug(MessageFormat.format("Marking product={0} as choosen.", product.getName())); //NOI18N
+ this.setValueInSession(product, session, HTTP_PARAM_CHOOSE, "1");
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
+ }
}
</thead>
<tbody class="table_body">
<%
- for (final Product product : app.getProducts()) {
+ // "Walk" through all products and unmark them as ordered
+ for (final Product product : app.getUnmarkedProducts(session)) {
%>
<tr>
<td>
// Is it choosen and amount set?
if (app.isProductChoosen(product, request, session)) {
// Then mark it as choosen
- product.markAsChoosen();
- app.unmarkProductAsOrdered(product, session);
+ app.markProductAsChoosen(product, session);
}
}
%>