Exemplo n.º 1
0
 @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";
 }
Exemplo n.º 2
0
 @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";
 }
Exemplo n.º 3
0
 @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";
 }
Exemplo n.º 4
0
 @RequestMapping(value = "/product/list", method = RequestMethod.GET)
 public String product(Model model) {
   model.addAttribute("productsList", productService.listProducts());
   return "productsList";
 }
Exemplo n.º 5
0
 @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";
 }