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;
/**
// 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
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
// 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);