@RequestMapping(method = RequestMethod.GET) public String showForm(Model model, HttpServletRequest request) { Child child = childManager.findChild(Integer.parseInt(request.getParameter("childId"))); child.setBills(billManager.findBillsForChild(child)); ChildEditForm form = new ChildEditForm(); form.setChild(child); model.addAttribute("formObject", form); model.addAttribute("rooms", roomManager.findAllActive()); model.addAttribute("typeOfAttendances", TypeOfAttendance.values()); model.addAttribute("ethnicityList", Ethnicity.values()); model.addAttribute("paymentList", PaymentType.values()); return "editChild"; }
@RequestMapping(params = "action=Save", method = RequestMethod.POST) public String saveChild(@ModelAttribute("formObject") ChildEditForm form) { childManager.saveChild(form.getChildWithNewData()); return "redirect:editChild.htm?childId=" + form.getChild().getId(); }