@RequestMapping(value = "/compromissos/new", method = RequestMethod.GET) public String initCreationForm(Agenda agenda, Map<String, Object> model) { Compromisso compromisso = new Compromisso(); agenda.addCompromisso(compromisso); model.put("compromisso", compromisso); return "compromissos/createOrUpdateCompromissoForm"; }
@RequestMapping(value = "/compromissos/new", method = RequestMethod.POST) public String processCreationForm( Agenda agenda, @Valid Compromisso compromisso, BindingResult result) { if (result.hasErrors()) { return "compromissos/createOrUpdateCompromissoForm"; } else { agenda.addCompromisso(compromisso); // this.clinicService.saveAgenda(agenda); this.clinicService.saveCompromisso(compromisso); return "redirect:/agendas/{agendaId}"; } }