List of usage examples for org.springframework.validation BindingResult hasErrors
boolean hasErrors();
From source file:technology.tikal.ventas.service.almacen.SalidaDevolucionService.java
@RequestMapping(value = "/{registroId}", method = RequestMethod.POST) public void actualizar(@PathVariable final Long pedidoId, @PathVariable final Long registroId, @Valid @RequestBody final RegistroAlmacenTransient request, final BindingResult result) { if (result.hasErrors()) { throw new NotValidException(result); }//from w w w .j av a 2s. c om if (Long.compare(request.getId(), registroId) != 0) { throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "NoValidRequest.EntradaDevolucionService.actualizar" }, new String[] { request.getId() + "" }, "El id del path no corresponde al de la info mandada en el body")); } salidaDevolucionController.actualizar(pedidoId, registroId, request); }
From source file:com.gantzgulch.sharing.controller.UserEditController.java
@RequestMapping(method = RequestMethod.POST) public ModelAndView processForm(@Valid UserForm userForm, BindingResult result, Map<String, Object> model) { if (result.hasErrors()) { ModelAndView modelAndView = new ModelAndView(".userEdit"); modelAndView.addObject("roleList", UserRole.getRoleList()); return modelAndView; }/*from w w w .j av a 2s . c o m*/ if (StringUtils.isBlank(userForm.getId())) { userManager.create(userForm); } else { userManager.update(userForm); } return new ModelAndView("redirect:/secure/admin/user.htm", "id", userForm.getId()); }
From source file:com.urservices.urerp.ecole.adresse.controller.AdresseController.java
@RequestMapping(value = "/update", method = RequestMethod.POST) public String updateAction(Adresse adresse, BindingResult bindingResult, SessionStatus sessionStatus) { if (bindingResult.hasErrors()) { return "adresse/edit"; } else {//from w ww .j a v a 2 s.c o m Adresse adresseTmp = iServiceAdresse.findById(adresse.getId()); adresseTmp = adresse; adresse = iServiceAdresse.save(adresseTmp); return "redirect:/adresse/" + adresse.getId() + "/show"; } }
From source file:mikeyp.spikes.controller.signup.SignupController.java
@RequestMapping(value = "/signup", method = RequestMethod.POST) public String signup(@Valid SignupForm form, BindingResult formBinding, WebRequest request) { if (formBinding.hasErrors()) { return null; }// w ww . jav a 2 s . c o m Account account = createAccount(form, formBinding); if (account != null) { authService.signin(account.getUsername()); ProviderSignInUtils.handlePostSignUp(account.getUsername(), request); return "redirect:/"; } return null; }
From source file:nl.enovation.addressbook.cqrs.webui.controllers.PhoneNumberController.java
@RequestMapping(value = "{contactIdentifier}/phonenumbers/{identifier}/delete", method = RequestMethod.POST) public String formDelete(@PathVariable String contactIdentifier, @ModelAttribute("phoneNumber") @Valid PhoneNumberEntry phoneNumber, BindingResult bindingResult) { if (!bindingResult.hasErrors()) { RemovePhoneNumberCommand command = new RemovePhoneNumberCommand( new StringAggregateIdentifier(contactIdentifier), phoneNumber.getPhoneNumber()); LOGGER.debug("Dispatching command with name : {}", command.toString()); commandBus.dispatch(command);//from w w w .ja v a 2 s.c o m return "redirect:/contacts/" + contactIdentifier; } return "phonenumbers/delete"; }
From source file:org.hdiv.spring.boot.sample.web.MainController.java
@RequestMapping(value = "/form", method = RequestMethod.POST) String submit(@Valid @ModelAttribute FormBean bean, BindingResult bindingResult, RedirectAttributes redirectAttributes) { if (bindingResult.hasErrors()) { return "form"; }// w w w .j a v a 2s .co m redirectAttributes.addFlashAttribute("resultFormBean", bean); LOG.info("Name: " + bean.getName() + " Type: " + bean.getType()); return "redirect:/form"; }
From source file:com.github.dbourdette.otto.web.controller.admin.MailController.java
@RequestMapping(value = "/mail/edit", method = RequestMethod.POST) public String edit(@ModelAttribute("form") MailConfiguration form, BindingResult result, Model model) { if (result.hasErrors()) { return "admin/mail_form"; }// w w w . j av a 2 s .co m mailer.saveConfiguration(form); flashScope.message("mail config has been modified"); return "redirect:/mail"; }
From source file:nl.enovation.addressbook.cqrs.webui.controllers.PhoneNumberController.java
@RequestMapping(value = "{contactIdentifier}/phonenumbers/new", method = RequestMethod.POST) public String formNewSubmit(@PathVariable String contactIdentifier, @Valid PhoneNumberEntry phoneNumber, BindingResult bindingResult) { if (bindingResult.hasErrors()) { return "phonenumbers/new"; }/* w w w . ja v a 2s . co m*/ Assert.notNull(contactIdentifier); CreatePhoneNumberCommand command = new CreatePhoneNumberCommand( new StringAggregateIdentifier(contactIdentifier), phoneNumber); LOGGER.debug("Dispatching command with name : {}", command.toString()); commandBus.dispatch(command); return "redirect:/contacts/" + contactIdentifier; }
From source file:org.jboss.as.quickstarts.kitchensink.spring.basic.controller.MemberController.java
@RequestMapping(method = RequestMethod.POST) public String registerNewMember(@Valid @ModelAttribute("newMember") Member newMember, BindingResult result, Model model) {/*from ww w . j av a 2 s .co m*/ if (!result.hasErrors()) { try { memberDao.register(newMember); return "redirect:/"; } catch (UnexpectedRollbackException e) { model.addAttribute("members", memberDao.findAllOrderedByName()); // Check the uniqueness of the email address if (emailAlreadyExists(newMember.getEmail())) { model.addAttribute("error", "Unique Email Violation"); } else { model.addAttribute("error", e.getCause().getCause()); } return "index"; } } else { model.addAttribute("members", memberDao.findAllOrderedByName()); return "index"; } }
From source file:com.training.controller.UserController.java
@RequestMapping(value = "/users/update", method = RequestMethod.POST) public String updateUser(@RequestParam(value = "id") Integer id, @RequestParam(value = "username") String newUsername, @RequestParam(value = "password") String newPassword, @RequestParam(value = "email") String newEmail, @Valid @ModelAttribute("userForm") UserFormValidator userForm, BindingResult bind, Model model) { if (bind.hasErrors()) { // model.addAttribute("messageUpdate", "Please fill the correct form in update"); return ("redirect:/users/view"); } else/*from ww w. j a va 2s . c om*/ userService.update(id, newUsername, newPassword, newEmail); return ("redirect:/users/view"); }