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:org.ahp.registration.controller.RegistrationController.java

@RequestMapping(method = RequestMethod.POST)
public String registerUser(HttpServletRequest pHttpServletRequest, @ModelAttribute("user") User pUser,
        BindingResult pBindingResult, Model pModel) throws IOException {
    System.out.println(pUser);//from  w  w  w. ja  v a 2  s .  com
    if (pBindingResult.hasErrors()) {
        return "/registration/Registration.jsp";
    }
    this.mRegistrationValidator.validate(pUser, pBindingResult);
    if (pBindingResult.hasErrors()) {
        return "/registration/Registration.jsp";
    }
    mRegistrationService.registerUser(pUser);
    pHttpServletRequest.getSession().setAttribute(LOGGED_IN_USER, pUser);
    return "redirect:/login/Home.jsp";
}

From source file:org.easit.core.controllers.twitter.TwitterTimelineController.java

@RequestMapping(value = "/twitter/tweet", method = RequestMethod.POST)
public String postTweet(@Valid UploadItem uploadItem, BindingResult result) {

    if (result.hasErrors()) {
        return null;
    }/*from w  w  w  . j av a  2s  .co m*/

    String message = uploadItem.getCaption();
    Resource photo = null;
    // StatusDetails details = null;
    if (!uploadItem.getFileData().isEmpty()) {
        final String fileName = uploadItem.getFileData().getOriginalFilename();
        photo = new ByteArrayResource(uploadItem.getFileData().getBytes()) {
            public String getFilename() throws IllegalStateException {
                return fileName;
            };
        };
        twitter.timelineOperations().updateStatus(message, photo);
        return "redirect:/twitter";
    } else {
        twitter.timelineOperations().updateStatus(message);
        return "redirect:/twitter";
    }

}

From source file:org.frat.common.validation.ValidateException.java

/**
 * /*from   w w  w.  j  av  a2 s  . c  o m*/
 * Description: TODO.
 * 
 * @param bindingResult
 * @return
 */
public boolean hasErrors(final BindingResult bindingResult) {
    return bindingResult.hasErrors();
}

From source file:technology.tikal.accounts.service.imp.AccountsImp.java

@Override
@RequestMapping(value = "/{user}/personalInfo", method = RequestMethod.POST)
public void updateAccountPersonalInfo(@PathVariable final String user,
        @Valid @RequestBody final PersonalInfo request, final BindingResult result) {
    if (result.hasErrors()) {
        throw new NotValidException(result);
    }/*from   ww  w . java 2  s  .c  o  m*/
    accountsController.updateAccount(user, request);
}

From source file:technology.tikal.accounts.service.imp.AccountsImp.java

@Override
@RequestMapping(value = "/{user}/role", method = RequestMethod.POST)
public void updateAccountRole(@PathVariable final String user, @Valid @RequestBody final Role request,
        final BindingResult result) {
    if (result.hasErrors()) {
        throw new NotValidException(result);
    }//from  w ww . j a v  a2 s. c  o  m
    accountsController.updateAccount(user, request);
}

From source file:technology.tikal.accounts.service.imp.AccountsImp.java

@Override
@RequestMapping(value = "/{user}/status", method = RequestMethod.POST)
public void updateAccountStatus(@PathVariable final String user, @Valid @RequestBody final Status request,
        final BindingResult result) {
    if (result.hasErrors()) {
        throw new NotValidException(result);
    }/*from   w ww .j av  a 2  s . c  o  m*/
    accountsController.updateAccount(user, request);
}

From source file:com.bangla.store.controller.EmployeeController.java

@RequestMapping(value = "/edit/{id}", method = RequestMethod.POST)
public String updateDetails(Model model, @Valid Employee employee, @PathVariable int id, BindingResult br,
        RedirectAttributes rAttributes) {

    if (br.hasErrors()) {
        model.addAttribute("employee", employee);
        return "employee/edit";
    } else {/* w w  w .ja  va2  s. c  om*/
        employeeService.update(employee);
        rAttributes.addFlashAttribute("message", "Successfully updated item");
        return "redirect:/employee";

    }

}

From source file:com.dub.skoolie.web.controller.system.people.faculty.SystemDistrictAdminController.java

@RequestMapping(value = "/system/people/faculty/districtadmin", method = RequestMethod.POST)
public ModelAndView addDistrictAdmin(@Valid DistrictAdminBean districtAdminBean, BindingResult result,
        Model model, HttpServletRequest request) {
    String referrer = request.getHeader("Referer");
    if (result.hasErrors()) {
        if (!referrer.equals("/system/people/faculty/districtadmin")) {
            return new ModelAndView("redirect:" + referrer);
        }//  w w w  .  j  ava  2s  .  c  o  m
    }
    uiDistrictAdminServiceImpl.addDistrictAdmin(districtAdminBean);
    return new ModelAndView("redirect:" + referrer);
}

From source file:com.dub.skoolie.web.controller.system.people.faculty.SystemSchoolAdminController.java

@RequestMapping(value = "/system/people/faculty/schooladmin", method = RequestMethod.POST)
public ModelAndView addSchoolAdmin(@Valid SchoolAdminBean schoolAdminBean, BindingResult result, Model model,
        HttpServletRequest request) {// w  w w. j a  va  2  s  .  c o  m
    String referrer = request.getHeader("Referer");
    if (result.hasErrors()) {
        if (!referrer.equals("/system/people/faculty/schooladmin")) {
            return new ModelAndView("redirect:" + referrer);
        }
    }
    uiSchoolAdminServiceImpl.addSchoolAdmin(schoolAdminBean);
    return new ModelAndView("redirect:" + referrer);
}

From source file:com.dub.skoolie.web.controller.system.people.faculty.SystemTeacherController.java

@RequestMapping(value = "/system/people/faculty/teacher", method = RequestMethod.POST)
public ModelAndView addTeacher(@Valid TeacherBean teacherBean, BindingResult result, Model model,
        HttpServletRequest request) {// ww w  .  ja v a  2s.  c o  m
    String referrer = request.getHeader("Referer");
    if (result.hasErrors()) {
        if (!referrer.equals("/system/people/faculty/teacher")) {
            return new ModelAndView("redirect:" + referrer);
        }
    }
    uiTeacherServiceImpl.addTeacher(teacherBean);
    return new ModelAndView("redirect:" + referrer);
}