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:cs544.letmegiveexam.controller.UserController.java

@RequestMapping(value = "/addUser", method = RequestMethod.POST)
public String addStudent(@Valid User user, BindingResult result) {
    if (result.hasErrors()) {
        return "register";
    } else {//from  ww  w.  j ava 2 s. c  o  m
        user.setEnabled(true);
        user.setLockCount(0);
        user.setLockTime(null);
        user.setRole_id(1);
        userServices.createUser(user);

        return "registerSuccess";
    }
}

From source file:com.test.swing1.mavenspringwebapplication.CategorieController.java

@RequestMapping(method = RequestMethod.POST)
public String saveBier(@ModelAttribute("BierCategorie") BierCategorie categorie, BindingResult result) {
    if (result.hasErrors()) {

        return "catgeorieform";
    } else {//from  w  w  w . j a  va2 s.  c o  m
        this.domain.createBierCategorie(categorie.getNaam());
        return "redirect:/categorie.htm";
    }
}

From source file:net.javacrumbs.codecamp.boot.MessagesController.java

@PostMapping
public String addMessage(@Valid Message message, BindingResult bindingResult) {
    if (bindingResult.hasErrors()) {
        return VIEW_NAME;
    }/*from w w w  . ja  v  a  2  s . c  om*/

    logger.addMessage(message);
    return "redirect:/messages";
}

From source file:net.noday.d4c.web.SubdomainController.java

@RequestMapping(method = RequestMethod.POST)
public String save(@Valid Subdomain obj, BindingResult result, Model m) {
    if (result.hasErrors()) {
        m.addAttribute(result.getFieldErrors());
    } else {/*from  ww w  .  j  a va 2s. co  m*/
        Long id = subdomainService.createSubdomain(obj);
        m.addAttribute("subdomain", null);
        responseData(m, id);
    }
    return null;
}

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

@RequestMapping(value = "/system/schedule/templates/schoolyear", method = RequestMethod.POST)
public ModelAndView addYearTemplate(@Valid SchoolYearTemplateBean schoolYearTemplateBean, BindingResult result,
        Model model) {/*from  ww w . ja va  2 s.c  o  m*/
    if (result.hasErrors()) {
        model.addAttribute("schoolYearTemplateBean", schoolYearTemplateBean);
        model.addAttribute("schoolYearTemplateBeans", uiSchoolYearTemplateServiceImpl.getSchoolYearTemplates());
        return new ModelAndView("system/schedule/templates/schoolyear");
    }
    uiSchoolYearTemplateServiceImpl.addSchoolYearTemplate(schoolYearTemplateBean);
    return new ModelAndView("redirect:/system/schedule/templates/schoolyear");
}

From source file:com.pegawai.app.controller.JabatanController.java

@RequestMapping(value = "form", method = RequestMethod.POST)
public String prosesForm(@ModelAttribute @Valid Jabatan k, BindingResult hasilValidasi) {
    if (hasilValidasi.hasErrors()) {
        return "/jabatan/form";
    }/*from www. j a va  2s. co m*/
    jabatanService.save(k);
    return "redirect:list";
}

From source file:mvc.controller.TarefaController.java

@RequestMapping("/alteraTarefa")
public String altera(@Valid Tarefa tarefa, BindingResult result) {
    if (result.hasErrors()) {
        return "tarefa/exibe-tarefa";
    }//from ww  w  .  jav a 2s  . c  om
    dao.alterarTarefa(tarefa);
    return "redirect:/listaTarefas";
}

From source file:com.github.jguaneri.notifications.web.controller.SignupController.java

@RequestMapping(method = RequestMethod.POST)
public String postSignup(@Valid @ModelAttribute("user") User user, BindingResult result) {
    if (result.hasErrors()) {
        return "signup";
    }//from  ww  w.j a v a2s  .com
    userService.createUser(user);
    return "redirect:login.html";
}

From source file:org.ucll.ip.spring_ip_project.controller.PlayerController.java

@RequestMapping(method = RequestMethod.POST, value = "edit")
public String editPlayer(@ModelAttribute("player") Player player, BindingResult result) {
    if (result.hasErrors()) {
        return "editPlayerForm";
    }/*from  w  w  w. j av a2 s  .c  o  m*/
    system.updatePlayer(player);
    return "redirect:/player.htm";
}

From source file:org.ucll.ip.spring_ip_project.controller.PlayerController.java

@RequestMapping(method = RequestMethod.POST, value = "save")
public String savePlayer(@ModelAttribute("player") Player player, BindingResult result) {
    if (result.hasErrors()) {
        return "playerForm";
    }/*  ww  w.ja  v a2s.c om*/
    system.addPlayer(player);
    return "redirect:/player.htm";
}