@Override public String execute() { DienthoaiDAO dao = new DienthoaiDAO(); Dienthoai dienthoai; if (masanpham == 0) return ERROR; dienthoai = dao.getDienthoaiById(masanpham); if (dienthoai == null) return ERROR; else { int q = sl; Map session = (Map) ActionContext.getContext().get("session"); Cart cart; cart = (Cart) session.get("cart"); if (cart == null) { cart = new Cart(); cart.addToCart(dienthoai, q); cart.optimizeCart(); } else { cart.addToCart(dienthoai, q); cart.optimizeCart(); } System.out.println("soluong = " + q); session.put("cart", cart); return SUCCESS; } }
@Override public String execute() throws Exception { DienthoaiDAO dao = new DienthoaiDAO(); System.out.println("inside ViewMobileByPriceAction"); System.out.println("minPrice = " + minPrice); System.out.println("maxPrice = " + maxPrice); dienthoais = dao.getDienthoaiByPriceRange(minPrice, maxPrice); // Dienthoai firstOne = dienthoais.get(0); // // ValueStack stack = ActionContext.getContext().getValueStack(); // Map<String, Object> context = new HashMap<String, Object>(); // context.put("firstOne", firstOne); // stack.push(context); return SUCCESS; }