@RequestMapping(value = "/product/remove/{id}", method = RequestMethod.GET) public String removeProductForm(@PathVariable("id") int id, Model model) { model.addAttribute("product", this.productService.getProductById(id)); model.addAttribute("invoicesListByProductId", productService.listInvoicesByProductId(id)); System.out.println(productService.listInvoicesByProductId(id).size()); return "removeProduct"; }
@RequestMapping(value = "/product/edit/{id}", method = RequestMethod.POST) public String processEditProductForm( @ModelAttribute("product") @Valid Product product, BindingResult result, Model model) { if (result.hasErrors()) { model.addAttribute("vatRatesList", vatRatesListMap); return "editProduct"; } productService.updateProduct(product); return "redirect:/product/list"; }
@RequestMapping(value = "/product/add", method = RequestMethod.POST) public String processAddNewProductForm( @ModelAttribute("newProduct") @Valid Product newProduct, BindingResult result, Model model) { if (result.hasErrors()) { model.addAttribute("vatRatesList", vatRatesListMap); return "addProduct"; } productService.addProduct(newProduct); return "redirect:/product/list"; }
@RequestMapping(value = "/product/list", method = RequestMethod.GET) public String product(Model model) { model.addAttribute("productsList", productService.listProducts()); return "productsList"; }
@RequestMapping(value = "/product/remove/{id}", method = RequestMethod.POST) public String processremoveProductForm( @ModelAttribute("product") @Valid Product product, BindingResult result) { productService.removeProduct(product.getId()); return "redirect:/product/list"; }