@RequestMapping(value = "/editItem", method = RequestMethod.POST) public String editItem( @ModelAttribute("itemEdit") ToDoItem toDoItem, BindingResult result, HttpServletRequest request) { toDoItem.setId(Integer.parseInt(request.getParameter("OldItemId"))); toDoItem.setCategory(categoryService.get(Integer.parseInt(request.getParameter("category")))); toDoItemService.update(toDoItem); return "redirect:/list"; }
@RequestMapping(value = "/addItem", method = RequestMethod.POST) public String addItem( @ModelAttribute("todoItem") ToDoItem todoItem, BindingResult result, HttpServletRequest request) { Category category = categoryService.get(Integer.parseInt(request.getParameter("category"))); todoItem.setCategory(category); toDoItemService.add(todoItem); return "redirect:/list"; }