From 4fe82c47c26af51851c7b0079b8c5798ca633e8d Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Sep 2015 14:17:28 +0200 Subject: [PATCH] =?utf8?q?Get=20the=20basket=20bean=20directly=20from=20se?= =?utf8?q?ssion=20scope=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../servlet/basket/BasketItemAddedFilter.java | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java b/src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java index 6de8edc8..66089c88 100644 --- a/src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java +++ b/src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java @@ -32,7 +32,6 @@ import org.mxchange.jcore.exceptions.BadTokenException; import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException; import org.mxchange.jshop.beans.basket.BasketBean; import org.mxchange.jshop.item.AddableBasketItem; -import org.mxchange.pizzaapplication.beans.controller.PizzaBean; import org.mxchange.pizzaapplication.filter.servlet.BaseServletFilter; /** @@ -72,10 +71,10 @@ public class BasketItemAddedFilter extends BaseServletFilter implements Filter { // item should not be null if (null == object) { // item is null - throw new NullPointerException("item is null"); //NOI18N + throw new NullPointerException("object is null"); //NOI18N } else if (!(object instanceof AddableBasketItem)) { // Not right instance - throw new IllegalArgumentException("item does not implement AddableBasketItem"); //NOI18N + throw new IllegalArgumentException("object does not implement AddableBasketItem"); //NOI18N } // Now it is secure to cast @@ -100,14 +99,8 @@ public class BasketItemAddedFilter extends BaseServletFilter implements Filter { throw new NullPointerException("session is null"); //NOI18N } - // Get man controller - PizzaBean bean = (PizzaBean) session.getAttribute("controller"); //NOI18N - - // Debug message - this.getLogger().debug(MessageFormat.format("bean={0}", bean)); //NOI18N - // Get basket instance - BasketBean basket = bean.getBasket(); + BasketBean basket = (BasketBean) session.getAttribute("basket"); //NOI18N // Debug message this.getLogger().debug(MessageFormat.format("basket={0}", basket)); //NOI18N @@ -133,14 +126,14 @@ public class BasketItemAddedFilter extends BaseServletFilter implements Filter { // Register item with it basket.addItem(item); - // Is amount null or zero? - if ((item.getAmount() == null) || (item.getAmount() == 0)) { - // Then redirect to added=0 - ((HttpServletResponse) response).sendRedirect(servletRequest.getContextPath() + "/?add=0"); //NOI18N - } else { - // Redirect to proper URL - ((HttpServletResponse) response).sendRedirect(servletRequest.getContextPath() + "/?add=1"); //NOI18N - } + // Is amount null or zero? + if ((item.getAmount() == null) || (item.getAmount() == 0)) { + // Then redirect to added=0 + ((HttpServletResponse) response).sendRedirect(servletRequest.getContextPath() + "/?add=0"); //NOI18N + } else { + // Redirect to proper URL + ((HttpServletResponse) response).sendRedirect(servletRequest.getContextPath() + "/?add=1"); //NOI18N + } } catch (final SQLException | BadTokenException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { // Continue to throw throw new ServletException(ex); -- 2.39.5