Example usage for org.springframework.validation BindException addAllErrors

List of usage examples for org.springframework.validation BindException addAllErrors

Introduction

In this page you can find the example usage for org.springframework.validation BindException addAllErrors.

Prototype

@Override
    public void addAllErrors(Errors errors) 

Source Link

Usage

From source file:org.mifos.ui.user.controller.CreateUserFormController.java

@Override
@SuppressWarnings({ "PMD.SignatureDeclareThrowsException", "PMD.OnlyOneReturn" })
//rationale: This is the signature of the superclass's method that we're overriding
//rationale: Forcing a single return, in code this simple, will make it more complex
//and harder to understand

protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
        BindException errors) throws Exception {

    UserFormBean userForm = (UserFormBean) command;
    try {//from   w  w w  . ja v a 2 s  .co m
        userService.createUser(userForm);
    } catch (MifosValidationException e) {
        errors.addAllErrors(e.getErrors());
        return showForm(request, response, errors);
    }

    Map<String, Object> model = new HashMap<String, Object>();
    model.put("user", command);
    return new ModelAndView("userCreateSuccess", "model", model);
}