/** * Displays an owner. * * @param ownerId the ID of the owner to display * @return view name */ @RequestMapping(value = "/{ownerId}", method = RequestMethod.GET) public String show(@PathVariable("ownerId") int ownerId, Model model) { Owner owner = clinic.loadOwner(ownerId); model.addAttribute(owner); return "owner/Detail"; }
/** Saves form data. */ @RequestMapping(value = "/save", method = RequestMethod.POST) public String save( @ModelAttribute("owner") Owner owner, BindingResult bindingResult, Model model) { new OwnerValidator().validate(owner, bindingResult); if (bindingResult.hasErrors()) { model.addAttribute( "allErrors", BindingResultUtils.getErrorMessages(bindingResult, messageSource)); return "owner/EditForm"; } clinic.storeOwner(owner); return "redirect:/owner/" + owner.getId(); }