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:technology.tikal.accounts.service.imp.AuthenticationImp.java

@Override
@RequestMapping(produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public AuthenticationResponse authenticate(@Valid @RequestBody final AuthenticationRequest request,
        final BindingResult result) {
    if (result.hasErrors()) {
        throw new NotValidException(result);
    }/*from   www. j a v  a 2 s. com*/
    AuthenticationResponse authResp = accountsController.authenticateUser(request);
    return authResp;
}

From source file:com.dub.skoolie.web.controller.admin.schedule.templates.AdminClassTimeBlockTemplateController.java

@RequestMapping(value = "/admin/schedule/templates/classtimeblock", method = RequestMethod.POST)
public ModelAndView addClassTimeBlockTemplate(@Valid ClassTimeBlockTemplateBean classTimeBlockTemplateBean,
        BindingResult result, Model model) {
    if (result.hasErrors()) {
        model.addAttribute("classTimeBlockTemplateBean", classTimeBlockTemplateBean);
        model.addAttribute("gradingPeriodTemplateBeans",
                uiClassTimeBlockTemplateService.getClassTimeBlockTemplates());
        return new ModelAndView("admin/schedule/templates/classtimeblock");
    }//from w w  w.j  a va 2 s . c o m
    uiClassTimeBlockTemplateService.addClassTimeBlockTemplate(classTimeBlockTemplateBean);
    return new ModelAndView("redirect:/admin/schedule/templates/classtimeblock");
}

From source file:com.dub.skoolie.web.controller.admin.schedule.templates.AdminGradingPeriodTemplateController.java

@RequestMapping(value = "/admin/schedule/templates/gradingperiod", method = RequestMethod.POST)
public ModelAndView addGradingPeriodTemplate(@Valid GradingPeriodTemplateBean gradingPeriodTemplateBean,
        BindingResult result, Model model) {
    if (result.hasErrors()) {
        model.addAttribute("gradingPeriodTemplateBean", gradingPeriodTemplateBean);
        model.addAttribute("gradingPeriodTemplateBeans",
                uiGradingPeriodTemplateServiceImpl.getGradingPeriodTemplates());
        return new ModelAndView("admin/schedule/templates/gradingperiod");
    }/*from w ww.  j  ava 2 s.  co m*/
    uiGradingPeriodTemplateServiceImpl.addGradingPeriodTemplate(gradingPeriodTemplateBean);
    return new ModelAndView("redirect:/admin/schedule/templates/gradingperiod");
}

From source file:com.dub.skoolie.web.controller.system.schedule.templates.SystemClassTimeBlockTemplateController.java

@RequestMapping(value = "/system/schedule/templates/classtimeblock", method = RequestMethod.POST)
public ModelAndView addClassTimeBlockTemplate(@Valid ClassTimeBlockTemplateBean classTimeBlockTemplateBean,
        BindingResult result, Model model) {
    if (result.hasErrors()) {
        model.addAttribute("classTimeBlockTemplateBean", classTimeBlockTemplateBean);
        model.addAttribute("gradingPeriodTemplateBeans",
                uiClassTimeBlockTemplateService.getClassTimeBlockTemplates());
        return new ModelAndView("system/schedule/templates/classtimeblock");
    }/*from w  ww  . j  ava  2  s .c o  m*/
    uiClassTimeBlockTemplateService.addClassTimeBlockTemplate(classTimeBlockTemplateBean);
    return new ModelAndView("redirect:/system/schedule/templates/classtimeblock");
}

From source file:com.dub.skoolie.web.controller.system.schedule.templates.SystemGradingPeriodTemplatecontroller.java

@RequestMapping(value = "/system/schedule/templates/gradingperiod", method = RequestMethod.POST)
public ModelAndView addGradingPeriodTemplate(@Valid GradingPeriodTemplateBean gradingPeriodTemplateBean,
        BindingResult result, Model model) {
    if (result.hasErrors()) {
        model.addAttribute("gradingPeriodTemplateBean", gradingPeriodTemplateBean);
        model.addAttribute("gradingPeriodTemplateBeans",
                uiGradingPeriodTemplateServiceImpl.getGradingPeriodTemplates());
        return new ModelAndView("system/schedule/templates/gradingperiod");
    }//from   www  . ja  va2s .  c o m
    uiGradingPeriodTemplateServiceImpl.addGradingPeriodTemplate(gradingPeriodTemplateBean);
    return new ModelAndView("redirect:/system/schedule/templates/gradingperiod");
}

From source file:spring.showcase.form.FrontController.java

@RequestMapping(value = "/create", method = RequestMethod.POST)
public String Index(@Valid User user, BindingResult result) {
    if (result.hasErrors()) {
        return "index";
    }//  ww w .j a  v a 2 s  .  co m
    list.add(user);
    return "index";
}

From source file:com.costrategix.user.web.UserController.java

@RequestMapping(method = RequestMethod.POST)
public String create(@Valid User user, BindingResult result) {
    if (result.hasErrors()) {
        return "user/createForm";
    }//from  ww  w  .jav a2s .  c  om
    userManager.save(user);
    return "redirect:/user/" + user.getId();
}

From source file:cz.cvut.portal.kos.portlet.search.EditSearchController.java

@ActionMapping
public void update(@Valid SearchPreferences preferences, BindingResult result, Model model) {
    if (!result.hasErrors()) {
        preferences.save();// ww w.  j  a v a 2  s .  c om
    }
}

From source file:org.dspace.webmvc.controller.LicenseEditController.java

@RequestMapping(params = "submit")
public String processForm(@RequestAttribute Context context, @Valid LicenseForm licenseForm,
        BindingResult bindingResult) {
    if (!bindingResult.hasErrors()) {
        ConfigurationManager.writeLicenseFile(I18nUtil.getDefaultLicense(context),
                licenseForm.getLicenseText());
        return "pages/admin/license-saved";
    }//from ww w  .j  av  a 2  s. c  o m

    return "pages/admin/license";
}

From source file:com.mascova.caliga.controller.LoginController.java

@RequestMapping(value = "/forget", method = RequestMethod.POST)
public String sendResetPassword(Model model, @Valid ForgetForm forgetForm, BindingResult result) {
    if (result.hasErrors()) {
        model.addAttribute("forgetForm", forgetForm);
        model.addAttribute("errorValidate", result.getAllErrors());
        return "page-lost-password";
    }/*from  w  w w . ja v a2s.c o  m*/
    User user = userService.findByEmail(forgetForm.getEmail());
    if (user == null) {
        model.addAttribute("errorMsg", "email not found");
        return "page-lost-password";
    }
    model.addAttribute("successMsg", "Please check your email to reset password");
    userService.resetPassword(user);

    return "page-lost-password";
}