@RequestMapping(value = "/edit/{id}", method = RequestMethod.GET) public ModelAndView editWishlistPage(@PathVariable Integer id) { ModelAndView modelAndView = new ModelAndView("edit-wishlist-form"); Wishlist wishlist = wishlistService.getResource(id); modelAndView.addObject("wishlist", wishlist); return modelAndView; }
@RequestMapping(value = "/delete/{id}", method = RequestMethod.GET) public ModelAndView deleteWishlist(@PathVariable Integer id) { ModelAndView modelAndView = new ModelAndView("home"); wishlistService.deleteResource(id); String message = "Wishlist was successfully deleted."; modelAndView.addObject("message", message); return modelAndView; }
@ResponseBody @RequestMapping(value = "/list", method = RequestMethod.GET, produces = "application/json") public List<Wishlist> listOfWishlists() { ModelAndView modelAndView = new ModelAndView("list-of-wishlists"); List<Wishlist> wishlists = wishlistService.getResources(); modelAndView.addObject("wishlists", wishlists); return wishlists; }
@RequestMapping(value = "/add", method = RequestMethod.POST) public ModelAndView addingWishlist(@ModelAttribute Wishlist wishlist) { ModelAndView modelAndView = new ModelAndView("home"); wishlistService.addResource(wishlist); String message = "Wishlist was successfully added."; modelAndView.addObject("message", message); return modelAndView; }
@RequestMapping(value = "/edit/{id}", method = RequestMethod.POST) public ModelAndView edditingWishlist( @ModelAttribute Wishlist wishlist, @PathVariable Integer id) { ModelAndView modelAndView = new ModelAndView("home"); wishlistService.updateResource(wishlist); String message = "Wishlist was successfully edited."; modelAndView.addObject("message", message); return modelAndView; }