List of usage examples for org.springframework.validation BindingResult hasErrors
boolean hasErrors();
From source file:com.pkrete.locationservice.admin.controller.mvc.EditLanguageController.java
@RequestMapping(method = RequestMethod.POST) public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, @ModelAttribute("language") Language language, BindingResult result) throws Exception { validator.validate(language, result); if (result.hasErrors()) { return new ModelAndView("edit_language", new ModelMap()); }/*from ww w . j a va2s . c o m*/ language.setUpdater(getUser(request).getUsername()); /* Save language to DB */ if (!languagesService.update(language)) { throw new Exception("Updating language failed."); } /* Update logged in user */ HttpSession session = request.getSession(); session.removeAttribute("user"); session.setAttribute("user", usersService.getUser(request.getRemoteUser())); /* Return to languages page */ return new ModelAndView( "redirect:languages.htm?select_language=" + request.getParameter("select_language")); }
From source file:com.rambird.miles.web.PetController.java
@RequestMapping(value = "/owners/{ownerId}/pets/new", method = RequestMethod.POST) public String processCreationForm(@ModelAttribute("pet") Pet pet, BindingResult result, SessionStatus status) { new PetValidator().validate(pet, result); if (result.hasErrors()) { return "pets/createOrUpdatePetForm"; } else {/*from w ww.j a va2s. c om*/ this.rambirdService.savePet(pet); status.setComplete(); return "redirect:/owners/{ownerId}"; } }
From source file:de.hybris.platform.yb2bacceleratorstorefront.controllers.pages.QuoteOnProductPageController.java
@RequestMapping(value = "/request/{productCode:.*}", method = RequestMethod.POST) @RequireHardLogIn//from w w w .j a va2 s . com public String productDetail(@PathVariable("productCode") final String productCode, @Valid final QuoteProductForm form, final BindingResult bindingResult) throws CMSItemNotFoundException, UnsupportedEncodingException { if (bindingResult.hasErrors()) { return ControllerConstants.Views.Fragments.ProductQuoteRequestPopup; } else { productQuote.createAndSave(form.getDescription(), productCode); return ControllerConstants.Views.Fragments.ProductQuoteRequestResult; } }
From source file:org.wallride.web.controller.guest.comment.CommentRestController.java
@RequestMapping(value = "/new", method = RequestMethod.POST) public CommentSavedModel create(@Validated CommentForm form, BindingResult result, BlogLanguage blogLanguage, AuthorizedUser authorizedUser) throws BindException { if (result.hasErrors()) { throw new BindException(result); }// www . j av a2 s .co m CommentCreateRequest request = form.toCommentCreateRequest(blogLanguage, authorizedUser); Comment comment = commentService.createComment(request, authorizedUser); return new CommentSavedModel(comment); }
From source file:ru.mystamps.web.controller.AccountController.java
@PostMapping(Url.ACTIVATE_ACCOUNT_PAGE) public String processActivationForm(@Validated({ LoginChecks.class, NameChecks.class, PasswordChecks.class, PasswordConfirmationChecks.class, ActKeyChecks.class, FormChecks.class }) ActivateAccountForm form, BindingResult result, RedirectAttributes redirectAttributes) { if (result.hasErrors()) { return null; }/*from ww w . ja va 2 s . co m*/ userService.registerUser(form); redirectAttributes.addFlashAttribute("justActivatedUser", true); return "redirect:" + Url.AUTHENTICATION_PAGE; }
From source file:technology.tikal.customers.service.ContactService.java
@RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED)/*from www .j av a2 s. c o m*/ public void createContact(@PathVariable final Long customerId, @Valid @RequestBody final Contact data, final BindingResult result, final HttpServletRequest request, final HttpServletResponse response) { if (result.hasErrors()) { throw new NotValidException(result); } Contact created = customersController.createContact(customerId, data); response.setHeader("Location", request.getRequestURI() + "/" + created.getId()); }
From source file:cherry.example.web.applied.ex10.AppliedEx13ControllerImpl.java
private boolean hasErrors(long id, int rownum, AppliedEx11Form form, BindingResult binding) { // ??/*from w w w. ja v a 2 s . c o m*/ if (binding.hasErrors()) { return true; } // ? if (form.getItem().get(rownum).getDt() == null && form.getItem().get(rownum).getTm() != null) { LogicalErrorUtil.rejectValue(binding, AppliedEx11Form.getItemPropName(rownum, Prop.Dt), LogicalError.RequiredWhen, AppliedEx11Form.resolveItemProp(rownum, Prop.Dt), AppliedEx11Form.resolveItemProp(rownum, Prop.Tm)); } if (binding.hasErrors()) { return true; } // ?? return false; }
From source file:cherry.example.web.applied.ex20.AppliedEx23ControllerImpl.java
private boolean hasErrors(long id, int rownum, AppliedEx21Form form, BindingResult binding) { // ??//from w ww. jav a2s . c om if (binding.hasErrors()) { return true; } // ? if (form.getItem().get(rownum).getDt() == null && form.getItem().get(rownum).getTm() != null) { LogicalErrorUtil.rejectValue(binding, AppliedEx21Form.getItemPropName(rownum, Prop.Dt), LogicalError.RequiredWhen, AppliedEx21Form.resolveItemProp(rownum, Prop.Dt), AppliedEx21Form.resolveItemProp(rownum, Prop.Tm)); } if (binding.hasErrors()) { return true; } // ?? return false; }
From source file:cherry.example.web.applied.ex30.AppliedEx32ControllerImpl.java
private boolean hasErrors(long id, int rownum, AppliedEx32Form form, BindingResult binding) { // ??//from w w w . jav a 2s.c o m if (binding.hasErrors()) { return true; } // ? if (form.getItem().get(rownum).getDt() == null && form.getItem().get(rownum).getTm() != null) { LogicalErrorUtil.rejectValue(binding, AppliedEx32Form.getItemPropName(rownum, Prop.Dt), LogicalError.RequiredWhen, AppliedEx32Form.resolveItemProp(rownum, Prop.Dt), AppliedEx32Form.resolveItemProp(rownum, Prop.Tm)); } if (binding.hasErrors()) { return true; } // ?? return false; }
From source file:cherry.example.web.applied.ex40.AppliedEx42ControllerImpl.java
private boolean hasErrors(long id, int rownum, AppliedEx42Form form, BindingResult binding) { // ??//from w ww. j a va2 s . c o m if (binding.hasErrors()) { return true; } // ? if (form.getItem().get(rownum).getDt() == null && form.getItem().get(rownum).getTm() != null) { LogicalErrorUtil.rejectValue(binding, AppliedEx42Form.getItemPropName(rownum, Prop.Dt), LogicalError.RequiredWhen, AppliedEx42Form.resolveItemProp(rownum, Prop.Dt), AppliedEx42Form.resolveItemProp(rownum, Prop.Tm)); } if (binding.hasErrors()) { return true; } // ?? return false; }