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:com.gym.controller.GrupoController.java

@RequestMapping(value = "/mod/{GrupoMuscular.id}", method = RequestMethod.POST)
public String modificaGrupo(@Valid GrupoMuscular grupo, BindingResult result,
        @PathVariable("GrupoMuscular.id") Integer grupoId) {
    grupo.setId(grupoId);//from  www .  j  a  v  a  2 s  .c o  m
    if (result.hasErrors()) {
        return "modgrupo";
    }
    grupoService.modifyGrupoMuscular(grupo);

    return "redirect:../gestgrupos";
}

From source file:com.izerui.user.UserController.java

@RequestMapping(value = "create", params = "confirm", method = RequestMethod.POST)
public String createConfirm(@Validated({ Default.class, UserCreateGroup.class }) UserForm form,
        BindingResult result) {
    if (result.hasErrors()) {
        return "user/createForm";
    }/*  w  w  w . ja  va2  s  . c o m*/
    return "user/createConfirm";
}

From source file:com.izerui.user.UserController.java

@RequestMapping(value = "update", params = "confirm", method = RequestMethod.POST)
public String updateConfirm(@Validated({ Default.class, UserUpdateGroup.class }) UserForm form,
        BindingResult result) {
    if (result.hasErrors()) {
        return "user/updateForm";
    }//from   ww  w. j  av  a2s .  co m
    return "user/updateConfirm";
}

From source file:cherry.example.web.validation.ex40.ValidationEx40ControllerImpl.java

private boolean hasErrors(ValidationEx40Form form, BindingResult binding) {

    // ??//from  ww w  .j  a v  a  2  s.com
    if (binding.hasErrors()) {
        return true;
    }

    // ?

    // ??

    return false;
}

From source file:abm.jakaria.school.ResultController.java

@RequestMapping(value = "/saveResult", method = RequestMethod.POST)
public String create(@ModelAttribute("newResult") Result result, BindingResult rresult, SessionStatus status) {
    validator.validate(result, rresult);
    if (rresult.hasErrors()) {
        return "newResult";
    }//from  ww w. ja  v  a 2 s.  co m
    resultDao.save(result);
    status.setComplete();
    return "redirect:viewAllResult.do";
}

From source file:abm.jakaria.school.ResultController.java

@RequestMapping(value = "/updateResult", method = RequestMethod.POST)
public String update(@ModelAttribute("editResult") Result result, BindingResult rresult, SessionStatus status) {
    validator.validate(result, rresult);
    if (rresult.hasErrors()) {
        return "editResult";
    }/*from w  w w .  j a v a 2 s.c om*/
    resultDao.update(result);
    status.setComplete();
    return "redirect:viewAllResult.do";
}

From source file:com.iselect.web.controller.admin.GeographicController.java

@RequestMapping(value = "/country/new", method = RequestMethod.POST)
public String newCountry(@Valid @ModelAttribute(COUNTRY) CountryDto country, BindingResult results,
        Model model) {/*  w ww.  j ava  2s  .com*/
    if (results.hasErrors()) {
        model.addAttribute(CRUD_MODEL, ISelectCRUDModel.EDIT.isReadOnly());
        return "geo.country";
    }
    geoService.saveCountry(country);
    return "redirect:./";
}

From source file:gallery.web.controller.pages.types.WallpaperAddType.java

@Override
public UrlBean execute(HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
        throws Exception {
    request.setAttribute(CATEGORIES_ATTR,
            pagesService.getAllCombobox(Boolean.TRUE, Boolean.TRUE, WallpaperGalleryType.TYPE));

    String action = request.getParameter(gallery.web.controller.Config.ACTION_PARAM_NAME);
    /** bind command */
    Wallpaper command = new Wallpaper();
    if ("addWallpaper".equals(action)) {
        BindingResult res = validator.bindAndValidate(command, request);
        if (res.hasErrors() || !wallpaperService.getImage(command)) {
            //m.putAll(res.getModel());
            request.setAttribute(res.MODEL_KEY_PREFIX + "command", res);
            request.setAttribute("command", command);
            common.CommonAttributes.addErrorMessage("form_errors", request);
        } else {//from  w  w w .  j  ava2 s.  c  o m
            //command.setUser(security.Utils.getCurrentUser(request));
            wallpaperService.save(command);
            request.setAttribute("command", new Wallpaper());
            common.CommonAttributes.addHelpMessage("operation_succeed", request);
        }
    } else {
        request.setAttribute("command", command);
    }

    UrlBean url = new UrlBean();
    url.setContent(contentUrl);

    return url;
}

From source file:com.branded.holdings.qpc.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  va 2 s . c o  m
        this.clinicService.savePet(pet);
        status.setComplete();
        return "redirect:/owners/{ownerId}";
    }
}

From source file:com.pet.demo.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 {//  w  ww  . ja v a2s .c o  m
        this.petDemoService.savePet(pet);
        status.setComplete();
        return "redirect:/owners/{ownerId}";
    }
}