@Test public void submitCreatePersonFormWithEmptyLastName() { MockHttpServletRequest mockRequest = new MockHttpServletRequest("/person/create", "POST"); PersonDTO created = PersonTestUtil.createDTO(null, FIRST_NAME, null); RedirectAttributes attributes = new RedirectAttributesModelMap(); BindingResult result = bindAndValidate(mockRequest, created); String view = controller.submitCreatePersonForm(created, result, attributes); verifyZeroInteractions(personServiceMock); assertEquals(PersonController.PERSON_ADD_FORM_VIEW, view); assertFieldErrors(result, FIELD_NAME_LAST_NAME); }
@RequestMapping(value = "/person/create", method = RequestMethod.POST) public String submitCreatePersonForm(@Valid @ModelAttribute(MODEL_ATTIRUTE_PERSON) PersonDTO created, BindingResult bindingResult, RedirectAttributes attributes) { LOGGER.debug("Create person form was submitted with information: " + created); if (bindingResult.hasErrors()) { return PERSON_ADD_FORM_VIEW; } Person person = personService.create(created); addFeedbackMessage(attributes, FEEDBACK_MESSAGE_KEY_PERSON_CREATED, person.getName()); return createRedirectViewPath(REQUEST_MAPPING_LIST); }
PersonController extends AbstractController { @RequestMapping(value = "/person/create", method = RequestMethod.POST) public String submitCreatePersonForm(@Valid @ModelAttribute(MODEL_ATTIRUTE_PERSON) PersonDTO created, BindingResult bindingResult, RedirectAttributes attributes) { LOGGER.debug("Create person form was submitted with information: " + created); if (bindingResult.hasErrors()) { return PERSON_ADD_FORM_VIEW; } Person person = personService.create(created); addFeedbackMessage(attributes, FEEDBACK_MESSAGE_KEY_PERSON_CREATED, person.getName()); return createRedirectViewPath(REQUEST_MAPPING_LIST); } }
PersonController extends AbstractController { @RequestMapping(value = "/person/create", method = RequestMethod.POST) public String submitCreatePersonForm(@Valid @ModelAttribute(MODEL_ATTIRUTE_PERSON) PersonDTO created, BindingResult bindingResult, RedirectAttributes attributes) { LOGGER.debug("Create person form was submitted with information: " + created); if (bindingResult.hasErrors()) { return PERSON_ADD_FORM_VIEW; } Person person = personService.create(created); addFeedbackMessage(attributes, FEEDBACK_MESSAGE_KEY_PERSON_CREATED, person.getName()); return createRedirectViewPath(REQUEST_MAPPING_LIST); }  }
PersonController extends AbstractController { @RequestMapping(value = "/person/create", method = RequestMethod.POST) public String submitCreatePersonForm(@Valid @ModelAttribute(MODEL_ATTIRUTE_PERSON) PersonDTO created, BindingResult bindingResult, RedirectAttributes attributes) { LOGGER.debug("Create person form was submitted with information: " + created); if (bindingResult.hasErrors()) { return PERSON_ADD_FORM_VIEW; } Person person = personService.create(created); addFeedbackMessage(attributes, FEEDBACK_MESSAGE_KEY_PERSON_CREATED, person.getName()); return createRedirectViewPath(REQUEST_MAPPING_LIST); }  @RequestMapping(value="/person/count", method = RequestMethod.POST) @ResponseBody Long count(@RequestBody SearchDTO searchCriteria); @RequestMapping(value = "/person/delete/{id}", method = RequestMethod.GET) String delete(@PathVariable("id") Long id, RedirectAttributes attributes); @RequestMapping(value = "/person/search/page", method = RequestMethod.POST) @ResponseBody List<PersonDTO> search(@RequestBody SearchDTO searchCriteria); @RequestMapping(value = "/person/create", method = RequestMethod.GET) String showCreatePersonForm(Model model); @RequestMapping(value = "/person/create", method = RequestMethod.POST) String submitCreatePersonForm(@Valid @ModelAttribute(MODEL_ATTIRUTE_PERSON) PersonDTO created, BindingResult bindingResult, RedirectAttributes attributes); @RequestMapping(value = "/person/edit/{id}", method = RequestMethod.GET) String showEditPersonForm(@PathVariable("id") Long id, Model model, RedirectAttributes attributes); @RequestMapping(value = "/person/edit", method = RequestMethod.POST) String submitEditPersonForm(@Valid @ModelAttribute(MODEL_ATTIRUTE_PERSON) PersonDTO updated, BindingResult bindingResult, RedirectAttributes attributes); @RequestMapping(value = REQUEST_MAPPING_LIST, method = RequestMethod.GET) String showList(Model model); @RequestMapping(value = "/person/search", method=RequestMethod.POST) String showSearchResultPage(@ModelAttribute(MODEL_ATTRIBUTE_SEARCH_CRITERIA) SearchDTO searchCriteria, Model model); }
PersonController extends AbstractController { @RequestMapping(value = "/person/create", method = RequestMethod.POST) public String submitCreatePersonForm(@Valid @ModelAttribute(MODEL_ATTIRUTE_PERSON) PersonDTO created, BindingResult bindingResult, RedirectAttributes attributes) { LOGGER.debug("Create person form was submitted with information: " + created); if (bindingResult.hasErrors()) { return PERSON_ADD_FORM_VIEW; } Person person = personService.create(created); addFeedbackMessage(attributes, FEEDBACK_MESSAGE_KEY_PERSON_CREATED, person.getName()); return createRedirectViewPath(REQUEST_MAPPING_LIST); }  @RequestMapping(value="/person/count", method = RequestMethod.POST) @ResponseBody Long count(@RequestBody SearchDTO searchCriteria); @RequestMapping(value = "/person/delete/{id}", method = RequestMethod.GET) String delete(@PathVariable("id") Long id, RedirectAttributes attributes); @RequestMapping(value = "/person/search/page", method = RequestMethod.POST) @ResponseBody List<PersonDTO> search(@RequestBody SearchDTO searchCriteria); @RequestMapping(value = "/person/create", method = RequestMethod.GET) String showCreatePersonForm(Model model); @RequestMapping(value = "/person/create", method = RequestMethod.POST) String submitCreatePersonForm(@Valid @ModelAttribute(MODEL_ATTIRUTE_PERSON) PersonDTO created, BindingResult bindingResult, RedirectAttributes attributes); @RequestMapping(value = "/person/edit/{id}", method = RequestMethod.GET) String showEditPersonForm(@PathVariable("id") Long id, Model model, RedirectAttributes attributes); @RequestMapping(value = "/person/edit", method = RequestMethod.POST) String submitEditPersonForm(@Valid @ModelAttribute(MODEL_ATTIRUTE_PERSON) PersonDTO updated, BindingResult bindingResult, RedirectAttributes attributes); @RequestMapping(value = REQUEST_MAPPING_LIST, method = RequestMethod.GET) String showList(Model model); @RequestMapping(value = "/person/search", method=RequestMethod.POST) String showSearchResultPage(@ModelAttribute(MODEL_ATTRIBUTE_SEARCH_CRITERIA) SearchDTO searchCriteria, Model model);  }