@RequestMapping(method = RequestMethod.GET) public String setupForm(@PathVariable("id") String id, Model model) { LiveActivityGroup group = activityRepository.getLiveActivityGroupById(id); LiveActivityGroupForm form = new LiveActivityGroupForm(); form.copyLiveActivityGroup(group); model.addAttribute("form", form); model.addAttribute("id", id); addGlobalModelItems(model); addNeededEntities(model); return "liveactivitygroup/LiveActivityGroupEdit"; }
@RequestMapping(method = {RequestMethod.PUT, RequestMethod.POST}) public String processSubmit( @PathVariable("id") String id, @ModelAttribute("form") LiveActivityGroupForm form, BindingResult result, SessionStatus status, Model model) { new LiveActivityGroupValidator().validate(form, result); if (result.hasErrors()) { addNeededEntities(model); return "liveactivitygroup/LiveActivityGroupEdit"; } else { LiveActivityGroup group = activityRepository.getLiveActivityGroupById(id); form.saveLiveActivityGroup(group, activityRepository); activityRepository.saveLiveActivityGroup(group); status.setComplete(); return "redirect:/liveactivitygroup/" + group.getId() + "/view.html"; } }