List of usage examples for org.springframework.validation BindingResult hasErrors
boolean hasErrors();
From source file:cz.muni.fi.mir.controllers.AnnotationValueController.java
@RequestMapping(value = { "/edit", "/edit/" }, method = RequestMethod.POST) public ModelAndView editSubmit( @Valid @ModelAttribute("annotationValueForm") AnnotationValueForm annotationValueForm, BindingResult result, Model model) { if (result.hasErrors()) { ModelMap mm = new ModelMap(); mm.addAttribute("annotationValueForm", annotationValueForm); mm.addAttribute(model);// www .java2 s.c o m } else { annotationValueSerivce.updateAnnotationValue(mapper.map(annotationValueForm, AnnotationValue.class)); } return new ModelAndView("redirect:/annotationvalue/"); }
From source file:com.mycompany.doctorapp.controller.SicknessController.java
@RequestMapping(value = "/sickness/{id}", method = RequestMethod.POST) public String orderTreatment(@Valid @ModelAttribute Treatment treatment, @PathVariable Long id, BindingResult bindingresult) { if (bindingresult.hasErrors()) { return "sickness/" + id; }// w w w . ja va2 s. c om Sickness sickness = sicknessRepository.findOne(id); treatmentService.treatSickness(treatment, sickness); return "redirect:/index"; }
From source file:$.$.java
/** * All the parameters are optional based on the necessity * /*from w ww.j a v a 2s.c o m*/ * @param httpSession * @param anyRequestObject * @param errors * @return */ @RequestMapping(method = RequestMethod.POST) public String onPost(HttpSession httpSession, @ModelAttribute("anyRequestObject") Object anyRequestObject, BindingResult errors) { if (errors.hasErrors()) { // return error view } return VIEW; }
From source file:com.springsource.oauthservice.develop.AppController.java
@RequestMapping(value = "/apps", method = RequestMethod.POST) public String create(Principal user, @Valid AppForm form, BindingResult bindingResult) { if (bindingResult.hasErrors()) { return "develop/apps/new"; }// ww w .j a v a2 s.com return "redirect:/develop/apps/" + appRepository.createApp(user.getName(), form); }
From source file:net.solarnetwork.util.BindingResultSerializer.java
@Override public Object serialize(Object data, String propertyName, Object propertyValue) { if (propertyValue == null) { return null; }//from w w w . j a v a 2 s . c o m if (!(propertyValue instanceof BindingResult)) { throw new IllegalArgumentException("Not a BindingResult: " + propertyValue.getClass()); } BindingResult br = (BindingResult) propertyValue; if (!br.hasErrors()) { return null; } Map<String, Object> map = new LinkedHashMap<String, Object>(); map.put("objectName", br.getObjectName()); map.put("errors", br.getAllErrors()); map.put("globalErrors", br.getGlobalErrors()); return map; }
From source file:com.springdemob.controllers.MainController.java
@RequestMapping(value = "/loginsubmit", method = RequestMethod.POST) @ResponseBody/*from ww w .j a v a 2s . c o m*/ public String LoginSubmit(@ModelAttribute("loginForm") @Validated LoginForm loginForm, BindingResult result, Model model) { if (result.hasErrors()) { return "Form has following Errors: " + result.getFieldErrors().get(0).toString(); } logger.info("user name:" + loginForm.getUsername()); logger.info("pass:" + loginForm.getPassword()); String rval = loginService.Authenticate(loginForm); return rval; }
From source file:org.fede.calculator.web.controller.MoneyCalculator.java
@RequestMapping(value = "/money", method = RequestMethod.POST) public MoneyDTO computeMoney(@RequestBody @Valid MoneyDTO money, BindingResult result) { if (result.hasErrors()) { MoneyDTO dto = new MoneyDTO(); dto.setValid(false);/*w w w . jav a2s . c om*/ dto.setMessage("El monto ingresado no es vlido."); return dto; } return this.moneyServices.get(money.getCurrency().getIso4217()).getMoney(money); }
From source file:br.com.compositeam.controller.MemberController.java
@RequestMapping(method = RequestMethod.POST) public String registerNewMember(@Valid @ModelAttribute("newMember") Member newMember, BindingResult result, Model model) {/*from w w w . j ava 2s. c om*/ if (!result.hasErrors()) { try { memberDao.register(newMember); return "redirect:/"; } catch (UnexpectedRollbackException e) { model.addAttribute("members", memberDao.findAllOrderedByName()); model.addAttribute("error", e.getCause().getCause()); return "index"; } } else { model.addAttribute("members", memberDao.findAllOrderedByName()); return "index"; } }
From source file:com.aplikasi.penjualan.controller.DataPelangganHtmlController.java
@RequestMapping(value = "/edit", method = RequestMethod.POST) public String prosesFormEdit(@Valid DataPelanggan k, BindingResult errors) { if (errors.hasErrors()) { return "/pelanggan/edit"; }//from w w w .ja v a2 s . co m kd.save(k); return "redirect:list"; }
From source file:com.aplikasi.penjualan.controller.DataPelangganHtmlController.java
@RequestMapping(value = "/form", method = RequestMethod.POST) public String prosesForm(@Valid DataPelanggan k, BindingResult errors) { if (errors.hasErrors()) { return "/pelanggan/form"; }/*from w w w. ja va 2 s .c om*/ kd.save(k); return "redirect:list"; }