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.urservices.urerp.ecole.adresse.controller.AdresseController.java

@RequestMapping(value = "/create", method = RequestMethod.POST)
public String createAction(@Valid Adresse adresse, BindingResult bindingResult, SessionStatus sessionStatus) {
    if (bindingResult.hasErrors()) {
        return "adresse/new";
    } else {//from ww  w  .j av  a  2s  . co  m
        adresse = iServiceAdresse.save(adresse);
        return "redirect:/adresse/" + adresse.getId() + "/show";
    }
}

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

@RequestMapping(value = "/owners/{ownerId}/pets/new", method = RequestMethod.POST)
public String processCreationForm(@Valid Pet pet, BindingResult result, SessionStatus status) {
    if (result.hasErrors()) {
        return "pets/petForm";
    } else {//w ww  .  j  av  a  2 s. com
        this.clinicService.savePet(pet);
        status.setComplete();
        return "redirect:/owners/{ownerId}";
    }
}

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

@RequestMapping(value = "/owners/{ownerId}/pets/{petId}/edit", method = RequestMethod.POST)
public String processUpdateForm(@Valid Pet pet, BindingResult result, SessionStatus status) {
    if (result.hasErrors()) {
        return "pets/petForm";
    } else {/*from   w  w  w .  j av a  2 s. com*/
        this.clinicService.savePet(pet);
        status.setComplete();
        return "redirect:/owners/{ownerId}";
    }
}

From source file:dochef.controller.SignupController.java

@RequestMapping(value = "/signup", method = RequestMethod.POST)
public String signup(@Valid SignupForm form, BindingResult formBinding, WebRequest request) {
    if (formBinding.hasErrors()) {
        return null;
    }/*from   w ww  .j  a  v a2  s . co m*/
    User user = createUser(form, formBinding);
    if (user != null) {
        SignInUtils.signin(user.getEmail()); //TODO REVISAR SI FUNCIONA CON EMAIL
        providerSignInUtils.doPostSignUp(user.getEmail(), request);
        return "redirect:/";
    }
    return null;
}

From source file:net.cyphoria.cylus.web.controller.KontoBearbeitenController.java

@RequestMapping(value = "/{kontoNummer}", method = POST)
public String speichereNeuenNamen(@ModelAttribute @Valid final Konto konto, final BindingResult bindingResult)
        throws BindException {
    if (bindingResult.hasErrors()) {
        return "konto/umbenennen";
    }/*  ww  w . j av  a2  s .  c  om*/

    kontoService.benenneKontoUm(konto);
    return "redirect:/kontenplan";
}

From source file:technology.tikal.ventas.service.almacen.EntradaService.java

@RequestMapping(value = "/{entradaId}", method = RequestMethod.POST)
public void actualizar(@PathVariable final Long pedidoId, @PathVariable final Long entradaId,
        @Valid @RequestBody final RegistroAlmacenTransient request, final BindingResult result) {
    if (result.hasErrors()) {
        throw new NotValidException(result);
    }//from  ww  w.  j a va  2 s  .  com
    if (Long.compare(request.getId(), entradaId) != 0) {
        throw new MessageSourceResolvableException(
                new DefaultMessageSourceResolvable(new String[] { "NoValidRequest.EntradaService.actualizar" },
                        new String[] { request.getId() + "" },
                        "El id del path no corresponde al de la info mandada en el body"));
    }
    entradaController.actualizar(pedidoId, entradaId, request);
}

From source file:technology.tikal.ventas.service.almacen.SalidaService.java

@RequestMapping(value = "/{registroId}", method = RequestMethod.POST)
public void actualizar(@PathVariable final Long pedidoId, @PathVariable final Long registroId,
        @Valid @RequestBody final RegistroAlmacenTransient request, final BindingResult result) {
    if (result.hasErrors()) {
        throw new NotValidException(result);
    }/*w w  w  . j  a va  2s . c  o m*/
    if (Long.compare(request.getId(), registroId) != 0) {
        throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable(
                new String[] { "NoValidRequest.EntradaDevolucionService.actualizar" },
                new String[] { request.getId() + "" },
                "El id del path no corresponde al de la info mandada en el body"));
    }
    salidaController.actualizar(pedidoId, registroId, request);
}

From source file:de.asgarbayli.rashad.hbd.controllers.ParametersController.java

@RequestMapping(value = Navigation.PARAMETERS, method = RequestMethod.POST)
public ModelAndView changeParameteres(@ModelAttribute(Navigation.PARAMETERS) Parameters parameters,
        BindingResult result, Model model) {
    // Check received data
    if (result.hasErrors()) {
        String message = "Binding result on " + Navigation.PARAMETERS
                + " has error(s) for the POST request method.";
        Messages.showErrorMessage(model, message);
        return new ModelAndView(Navigation.PARAMETERS);
    }//from w  w w .java2  s  . c  o m

    // Process the received data
    parameters.saveParameters();

    // Log
    String message = "Parameters were successfully changed.";
    Messages.showSuccessMessage(model, message);

    // Done, reload and show on the same page
    return new ModelAndView(Navigation.PARAMETERS, "command", parameters);
}

From source file:org.home.petclinic2.controller.VisitController.java

/**
 * Handles visit validation and saves the visit
 * /*from w ww.  j  a  va 2s  .co  m*/
 * @param visit
 * @param result
 * @param petId
 * @return
 */
@RequestMapping(value = "/owner/{ownerId}/pet/{petId}/visit/new", method = RequestMethod.POST)
public String processNewVisitForm(@Valid Visit visit, BindingResult result, @PathVariable int petId) {
    if (result.hasErrors()) {
        return "pet/visit";
    } else {
        Pet pet = clinicService.findPetById(petId);
        visit.setPet(pet);
        clinicService.saveVisit(visit);
        return "redirect:/owner/{ownerId}";
    }
}

From source file:technology.tikal.ventas.service.almacen.EntradaDevolucionService.java

@RequestMapping(value = "/{registroId}", method = RequestMethod.POST)
public void actualizar(@PathVariable final Long pedidoId, @PathVariable final Long registroId,
        @Valid @RequestBody final RegistroAlmacenTransient request, final BindingResult result) {
    if (result.hasErrors()) {
        throw new NotValidException(result);
    }/*ww w. j a  v  a 2 s.co m*/
    if (Long.compare(request.getId(), registroId) != 0) {
        throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable(
                new String[] { "NoValidRequest.EntradaDevolucionService.actualizar" },
                new String[] { request.getId() + "" },
                "El id del path no corresponde al de la info mandada en el body"));
    }
    entradaDevolucionController.actualizar(pedidoId, registroId, request);
}