List of usage examples for org.springframework.validation BindingResult hasFieldErrors
boolean hasFieldErrors(String field);
From source file:com.bh.subject.std.common.error.BindResultExceptionRaiser.java
public static void raiseBindingResultException(List<String> fieldNames, BindingResult bindingResult) { for (String errorField : fieldNames) { if (bindingResult.hasFieldErrors(errorField)) { throw new GMSException(bindingResult.getFieldError(errorField)); }/* w w w .j ava 2s. c o m*/ } }
From source file:es.jffa.tsc.sip04.web.AccountController.java
/** * * @param result/*from www . j a v a 2 s. c o m*/ */ private static void _convertPasswordError(final BindingResult result) { for (ObjectError error : result.getGlobalErrors()) { String msg = error.getDefaultMessage(); if ("account.password.mismatch.message".equals(msg) == true) { if (result.hasFieldErrors("password") == false) result.rejectValue("password", "error.mismatch"); } } }
From source file:vn.edu.vnuk.tasks_jpa.controller.TasksController.java
@RequestMapping("createTask") public String create(@Valid Task task, BindingResult result) throws SQLException { if (result.hasFieldErrors("description")) { return "task/add"; }/* w ww.j ava 2s .c om*/ dao.create(task); return "task/added"; }
From source file:vn.edu.vnuk.tasks_jpa.controller.TasksController.java
@RequestMapping("updateTask") public String update(@Valid Task task, BindingResult result) throws SQLException { if (result.hasFieldErrors("description")) { return "task/edit"; }/* w ww . j av a 2 s .c o m*/ dao.update(task); return "task/updated"; }
From source file:vn.edu.vnuk.tasks.controller.TasksController.java
@RequestMapping("createTask") public String create(@Valid Task task, BindingResult result) throws SQLException { if (result.hasFieldErrors("description")) { return "task/add"; }//from w w w. jav a2s .co m new TaskDao().create(task); return "task/added"; }
From source file:vn.edu.vnuk.tasks.controller.TasksController.java
@RequestMapping("updateTask") public String update(@Valid Task task, BindingResult result) throws SQLException { if (result.hasFieldErrors("description")) { return "task/edit"; }// w w w. ja va 2 s .c o m new TaskDao().update(task); return "task/updated"; }
From source file:org.wallride.web.controller.guest.comment.CommentRestController.java
@RequestMapping(value = "/{id}", method = RequestMethod.PUT) public CommentSavedModel update(@PathVariable long id, @Validated CommentForm form, BindingResult result, AuthorizedUser authorizedUser) throws BindException { if (result.hasFieldErrors("content")) { throw new BindException(result); }//from w w w .j a va 2 s.c o m CommentUpdateRequest request = form.toCommentUpdateRequest(id); Comment comment = commentService.updateComment(request, authorizedUser); return new CommentSavedModel(comment); }
From source file:com.senfino.yodo.controller.AccontController.java
private void convertPasswordError(BindingResult bindingResult) { for (ObjectError objectError : bindingResult.getGlobalErrors()) { String msg = objectError.getDefaultMessage(); if ("account.password.mismatch.message".equals(msg)) { if (bindingResult.hasFieldErrors("password")) { bindingResult.rejectValue("password", "error.mismatch"); }//from ww w . j a v a 2 s.c om } } }
From source file:eu.trentorise.smartcampus.permissionprovider.auth.internal.RegistrationController.java
@RequestMapping(value = "/changepwd", method = RequestMethod.POST) public String changePwd(Model model, @ModelAttribute("reg") @Valid RegistrationBean reg, BindingResult result, HttpServletRequest req) {// w ww. j a v a2 s .c o m if (result.hasFieldErrors("password")) { return "registration/changepwd"; } String userMail = (String) req.getSession().getAttribute("changePwdEmail"); if (userMail == null || !userMail.equals(reg.getEmail())) { model.addAttribute("error", RegistrationException.class.getSimpleName()); return "registration/changepwd"; } req.getSession().removeAttribute("changePwdEmail"); try { manager.updatePassword(reg.getEmail(), reg.getPassword()); } catch (RegistrationException e) { e.printStackTrace(); model.addAttribute("error", e.getClass().getSimpleName()); return "registration/changepwd"; } return "registration/changesuccess"; }
From source file:org.wallride.web.controller.guest.user.PasswordUpdateController.java
@RequestMapping(method = RequestMethod.PUT) public String update(@Validated @ModelAttribute(FORM_MODEL_KEY) PasswordUpdateForm form, BindingResult errors, AuthorizedUser authorizedUser, RedirectAttributes redirectAttributes) { redirectAttributes.addFlashAttribute(FORM_MODEL_KEY, form); redirectAttributes.addFlashAttribute(ERRORS_MODEL_KEY, errors); if (!errors.hasFieldErrors("newPassword")) { if (!ObjectUtils.nullSafeEquals(form.getNewPassword(), form.getNewPasswordRetype())) { errors.rejectValue("newPasswordRetype", "MatchRetype"); }//from w w w . ja v a 2 s . co m } if (!errors.hasErrors()) { User user = userService.getUserById(authorizedUser.getId()); PasswordEncoder passwordEncoder = new StandardPasswordEncoder(); if (!passwordEncoder.matches(form.getCurrentPassword(), user.getLoginPassword())) { errors.rejectValue("currentPassword", "MatchCurrentPassword"); } } if (errors.hasErrors()) { return "redirect:/settings/password?step.edit"; } PasswordUpdateRequest request = new PasswordUpdateRequest().withUserId(authorizedUser.getId()) .withPassword(form.getNewPassword()); userService.updatePassword(request, authorizedUser); redirectAttributes.getFlashAttributes().clear(); redirectAttributes.addFlashAttribute("updatedPassword", true); return "redirect:/settings/password"; }