@RequestMapping(value = "/edit/{id}", method = RequestMethod.POST) public String editForm( ModelMap mm, @PathVariable("id") short id, HttpSession session, HttpServletRequest request, HttpServletResponse response) { String action = request.getParameter("btAction"); if (action.equals("Cancel")) { return "redirect:../show"; } else { PillProvider PillProvider = PillProviderService.findById(id); String code = request.getParameter("code"); String description = request.getParameter("description"); String address = request.getParameter("address"); String phone = request.getParameter("phone"); String email = request.getParameter("email"); PillProvider.setCode(code); PillProvider.setDescription(description); PillProvider.setAddress(address); PillProvider.setPhone(phone); PillProvider.setEmail(email); PillProviderService.update(PillProvider); return "redirect:../show"; } }
@RequestMapping(value = "/add", method = RequestMethod.POST) public String addForm( ModelMap mm, HttpSession session, HttpServletRequest request, HttpServletResponse response) { String action = request.getParameter("btAction"); if (action.equals("Cancel")) { return "redirect:show"; } else { PillProvider PillProvider = new PillProvider(); String code = request.getParameter("code"); String description = request.getParameter("description"); String address = request.getParameter("address"); String phone = request.getParameter("phone"); String email = request.getParameter("email"); PillProvider.setCode(code); PillProvider.setDescription(description); PillProvider.setAddress(address); PillProvider.setPhone(phone); PillProvider.setEmail(email); PillProviderService.create(PillProvider); return "redirect:show"; } }