public ModelAndView test(HttpServletRequest request, HttpServletResponse response) { System.out.println("Inside Controller****************test:" + productService); ModelAndView mv = new ModelAndView("test"); // check if cart is present // session.get // System.out.println(productService); List<Product> products = productService.getAllEntities(); Product added = new Product(); added.setName("new!!!"); added.setPrice(BigDecimal.valueOf(1200.25)); added = productService.add(added); Customer cust = new Customer(); cust.setName("dude"); cust.setEmail("*****@*****.**"); cust.setCustomerId(cust.getEmail()); // customerService.add(cust); Order order = new Order(); order.setName("new order"); order.setCustomer(cust); orderService.add(order); System.out.println("order " + order.getId()); mv.addObject("msg", products.size()); // mv.addObject("added", added.getId()); return mv; }
public ModelAndView home( HttpServletRequest request, HttpServletResponse response, HttpSession session) { System.out.println("Inside Controller****************home"); // create shopping cart if (session.getAttribute("CART") == null) { Cart cart = new Cart(); session.setAttribute("CART", cart); } ModelAndView mv = new ModelAndView("index"); List<Product> products = productService.getAllEntities(); int i = 1; for (Product p : products) { mv.addObject("prod_" + i, p.getName()); mv.addObject("shortDesc_" + i, p.getShortDescription()); mv.addObject("prodId_" + i, p.getId()); mv.addObject("prodPrice_" + i, p.getPrice()); mv.addObject("img_" + i++, p.getImg()); } mv.addObject("msg", "Welcome!!!"); return mv; }