Example usage for org.springframework.validation BindingResult hasErrors

List of usage examples for org.springframework.validation BindingResult hasErrors

Introduction

In this page you can find the example usage for org.springframework.validation BindingResult hasErrors.

Prototype

boolean hasErrors();

Source Link

Document

Return if there were any errors.

Usage

From source file:org.smigo.user.password.PasswordController.java

@RequestMapping(value = "/reset-password", method = RequestMethod.POST)
public String setPassword(@Valid ResetKeyPasswordFormBean resetFormBean, BindingResult result) {
    if (result.hasErrors()) {
        return "resetpasswordform.jsp";
    }/*from w  ww . j  av a 2s.  c  o m*/
    userHandler.setPassword(resetFormBean);
    return "redirect:/login";
}

From source file:technology.tikal.accounts.service.imp.RolesImp.java

@Override
@RequestMapping(produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public Page<List<Role>> queryRoles(@Valid @ModelAttribute PaginationDataString pagination,
        BindingResult paginationResult, HttpServletRequest request) {
    if (paginationResult.hasErrors()) {
        throw new NotValidException(paginationResult);
    }//from   www  .  j ava  2s  . co m
    Page<List<Role>> r = PaginationModelFactory.getPage(sessionController.queryRoles(pagination), "role",
            request.getRequestURI(), null, pagination);
    return r;
}

From source file:com.example.session.app.account.AccountCreateController.java

@RequestMapping(value = "create", params = "confirm")
public String confirmCreate(@Validated AccountCreateForm form, BindingResult result) {

    if (result.hasErrors()) {
        return showCreateForm();
    }/*from   w  w w  . j  a va 2  s .co  m*/

    return "account/createConfirm";
}

From source file:com.library.bookarticlelibrary.controller.BooksController.java

@RequestMapping(value = { "/books/savebook", "/books/book/editbook/savebook" }, method = RequestMethod.POST)
public ModelAndView saveBook(@Valid Book book, BindingResult bookResult) {
    if (bookResult.hasErrors()) {
        return new ModelAndView("addbook");
    }/*from  w  w w  . j av  a 2 s.c  o  m*/
    List<Author> authors = book.getAuthors();
    List<Author> checkedAuthors = new ArrayList<>();
    for (Author author : authors) {
        author = authorDao.getAuthorByName(author.getFirstname(), author.getLastname());
        checkedAuthors.add(author);
    }
    book.setAuthors(checkedAuthors);
    bookDao.saveOrUpdate(book);

    return new ModelAndView("redirect:/library/books");

}

From source file:com.work.petclinic.web.VisitController.java

@RequestMapping(value = "/owners/{ownerId}/pets/{petId}/visits/new", method = RequestMethod.POST)
public String processNewVisitForm(@Valid Visit visit, BindingResult result, SessionStatus status) {
    if (result.hasErrors()) {
        return "pets/visitForm";
    } else {//from   w w  w.j a va 2 s .c om
        this.clinicService.saveVisit(visit);
        status.setComplete();
        return "redirect:/owners/{ownerId}";
    }
}

From source file:info.harmia.polyglot.springapp.mvc.web.controller.DepartmentController.java

@RequestMapping(value = "/departments/add", method = RequestMethod.POST)
public String addDepartment(@ModelAttribute("department") @Valid DepartmentForm departmentForm,
        BindingResult result, ModelMap model, HttpSession session) {
    if (result.hasErrors()) {
        FlashMessage.createErrorMessage(session, "departments.add.error", departmentForm.getName());
        return listDepartments(departmentForm, model);
    }//from   ww w  .j av  a  2  s  .c o m
    departmentService.addDepartment(departmentForm);
    FlashMessage.createSuccessMessage(session, "departments.add.success", departmentForm.getName());
    return "redirect:/departments/";
}

From source file:org.ng200.openolympus.controller.user.UserInfoController.java

@RequestMapping(method = RequestMethod.POST)
public String changePersonInfo(Model model, @Valid final UserInfoDto userInfoDto,
        final BindingResult bindingResult, final Principal principal) {
    if (bindingResult.hasErrors()) {
        model.addAttribute("postUrl", "/user");
        model.addAttribute("changePasswordLink", "/user/changePassword");
        return "user/personalInfo";
    }//from  w  ww .j  a v  a 2 s .  c  o  m
    super.copyDtoIntoDatabase(userInfoDto, bindingResult, userRepository.findByUsername(principal.getName()));
    return "redirect:/";
}

From source file:$.MemberController.java

@RequestMapping(method = RequestMethod.POST)
    public String registerNewMember(@Valid @ModelAttribute("newMember") Member newMember, BindingResult result,
            Model model) {//w w w.j  a  v a2 s .c o m
        if (!result.hasErrors()) {
            try {
                memberDao.register(newMember);
                return "redirect:/";
            } catch (UnexpectedRollbackException e) {
                model.addAttribute("members", memberDao.findAllOrderedByName());
                model.addAttribute("error", e.getCause().getCause());
                return "index";
            }
        } else {
            model.addAttribute("members", memberDao.findAllOrderedByName());
            return "index";
        }
    }

From source file:com.iselect.web.controller.AccountController.java

@RequestMapping(value = "/new", method = RequestMethod.POST)
public String postAccount(@ModelAttribute(value = "account") @Valid UserDto userDto, BindingResult results)
        throws EntityNotFoundException {
    if (results.hasErrors())
        return "account.details";

    accountService.insertOrUpdateUser(userDto);

    return "redirect:./index";
}

From source file:ems.emsystem.controller.DepartmentController.java

@RequestMapping(value = { "/edit" }, method = RequestMethod.POST)
public String editDepartment(@Valid Department dep, BindingResult br) {
    if (br.hasErrors()) {
        return "editDepartment";
    }/*from   w w  w . java  2s  . c  om*/
    departmentService.editDepartment(dep);
    return "redirect: /" + dep.getId();
}