List of usage examples for org.springframework.validation BindingResult hasErrors
boolean hasErrors();
From source file:com.branded.holdings.qpc.web.VisitController.java
@RequestMapping(value = "/owners/{ownerId}/pets/{petId}/visits/new", method = RequestMethod.POST) public String processNewVisitForm(@Valid Visit visit, BindingResult result) { if (result.hasErrors()) { return "pets/createOrUpdateVisitForm"; } else {// w w w .j ava 2s . co m this.clinicService.saveVisit(visit); return "redirect:/owners/{ownerId}"; } }
From source file:com.rorrell.zootest.controllers.ExhibitController.java
@RequestMapping(value = "/exhibit/save", method = RequestMethod.POST) public String saveExhibit(@Valid Exhibit exhibit, BindingResult result) { if (result.hasErrors()) { return "exhibitform"; }// w ww . j av a 2s . c om //make sure first letter of name is capitalized exhibit.setName(Character.toUpperCase(exhibit.getName().charAt(0)) + exhibit.getName().substring(1)); exRepo.save(exhibit); return "redirect:/exhibits"; }
From source file:videoshop.controller.ShopController.java
@RequestMapping("/registerNew") public String registerNew(@ModelAttribute("registrationForm") @Valid RegistrationForm registrationForm, BindingResult result) { if (result.hasErrors()) { return "register"; }/*from www . ja v a 2s. c o m*/ // () // Falles alles in Ordnung ist legen wir einen UserAccount und einen passenden Customer an und speichern beides. UserAccount userAccount = userAccountManager.create(registrationForm.getName(), registrationForm.getPassword(), new Role("ROLE_CUSTOMER")); userAccountManager.save(userAccount); Customer customer = new Customer(userAccount, registrationForm.getAddress()); customerRepository.save(customer); return "redirect:/"; }
From source file:com.thesoftwareguild.addressbook.controller.HomeControllerNoAjax.java
@RequestMapping(value = "/editAddressNoAjax", method = RequestMethod.POST) public String editAddressNoAjax(@Valid @ModelAttribute("address") Address address, BindingResult result) { if (result.hasErrors()) { return "editAddressFormNoAjax"; }//from w w w .ja v a2s.c om dao.updateAddress(address); return "redirect:displayAddressBookNoAjax"; }
From source file:sample.mvc.MessageController.java
@RequestMapping(method = RequestMethod.POST) public ModelAndView create(@Valid Message message, BindingResult result, RedirectAttributes redirect) { if (result.hasErrors()) { return new ModelAndView("messages/form"); }/* w w w . j a v a 2 s .c om*/ message = messageRepository.save(message); redirect.addFlashAttribute("globalMessage", "Successfully created a new message"); return new ModelAndView("redirect:/messages/{message.id}", "message.id", message.getId()); }
From source file:org.openmrs.module.atlas.web.controller.AtlasModuleFormController.java
/** * All the parameters are optional based on the necessity * /* ww w . j a va 2 s. c om*/ * @param httpSession * @param anyRequestObject * @param errors * @return */ @RequestMapping(method = RequestMethod.POST) public String onSubmit(HttpSession httpSession, @ModelAttribute("anyRequestObject") Object anyRequestObject, BindingResult errors) { if (errors.hasErrors()) { // return error view } return SUCCESS_FORM_VIEW; }
From source file:com.rorrell.zootest.controllers.AnimalController.java
@RequestMapping(value = "/animal/save", method = RequestMethod.POST) public String saveAnimal(@Valid Animal animal, BindingResult result) { if (result.hasErrors()) return "animalform"; //make sure first letter of type is capitalized animal.setType(Character.toUpperCase(animal.getType().charAt(0)) + animal.getType().substring(1)); animalRepo.save(animal);/*from www . j a v a 2 s . co m*/ return "redirect:/animals"; }
From source file:com.swcguild.contactlistmvc.controller.HomeControllerNoAjax.java
@RequestMapping(value = "/editContactNoAjax", method = RequestMethod.POST) public String editContactNoAjax(@Valid @ModelAttribute("contact") Contact contact, BindingResult result) { if (result.hasErrors()) { return "editContactFormNoAjax"; }/* www. j av a 2s. c om*/ dao.updateContact(contact); return "redirect:displayContactListNoAjax"; }
From source file:pl.altkom.text.mvc.spring.controller.PersonController.java
@RequestMapping(value = "add", method = RequestMethod.POST) public String savePerson(@Valid Person person, BindingResult binding) { if (binding.hasErrors()) { return "addPerson"; } else {/*from ww w .j a v a 2s . c o m*/ System.out.println(person); personDAO.save(person); return "redirect:/person/list.htm"; } }
From source file:pl.com.softproject.altkom.hibernate.forms.web.controller.FormCreateController.java
@RequestMapping(value = "/saveForm", method = RequestMethod.POST) public String saveForm(@Valid Form form, BindingResult result) { if (result.hasErrors()) { return "addForm"; }/*from w ww . jav a2s . c om*/ form.setCreateDate(new Date()); formDAO.save(form); return "redirect:/showForms.htm"; }