List of usage examples for org.springframework.validation BindingResult hasErrors
boolean hasErrors();
From source file:cherry.example.web.applied.ex60.AppliedEx62ControllerImpl.java
private boolean hasErrors(AppliedEx62Form form, BindingResult binding) { // ??//from w ww . java2 s .c om if (binding.hasErrors()) { return true; } // ? if (form.getDt() == null && form.getTm() != null) { LogicalErrorUtil.rejectValue(binding, Prop.Dt.getName(), LogicalError.RequiredWhen, Prop.Dt.resolve(), Prop.Tm.resolve()); } if (binding.hasErrors()) { return true; } // ?? return false; }
From source file:com.dub.skoolie.web.controller.system.school.rooms.SystemSchoolRoomController.java
@RequestMapping(value = "/system/schools/{id}/rooms", method = RequestMethod.POST) public ModelAndView addSchoolRoom(@PathVariable("id") Long schoolid, @Valid SchoolRoomBean schoolRoomBean, BindingResult result, Model model, HttpServletRequest request) { String referrer = request.getHeader("Referer"); if (result.hasErrors()) { if (!referrer.equals("/system/schools/" + schoolid + "/rooms")) { return new ModelAndView("redirect:" + referrer); }/*from w w w . jav a 2 s . c o m*/ return new ModelAndView("system/school/schools"); } uiSchoolRoomServiceImpl.addSchoolRoom(schoolRoomBean); return new ModelAndView("redirect:" + referrer); }
From source file:com.jnj.b2b.storefront.controllers.misc.AddToCartController.java
@RequestMapping(value = "/cart/add", method = RequestMethod.POST, produces = "application/json") public String addToCart(@RequestParam("productCodePost") final String code, final Model model, @Valid final AddToCartForm form, final BindingResult bindingErrors) { if (bindingErrors.hasErrors()) { return getViewWithBindingErrorMessages(model, bindingErrors); }/*from ww w .j a v a 2 s . co m*/ final OrderEntryData orderEntryData = getOrderEntryData(form.getQty(), code, null); final CartModificationData modification = cartFacade.addOrderEntry(orderEntryData); model.addAttribute("numberShowing", Config.getInt(SHOWN_PRODUCT_COUNT, 3)); model.addAttribute("modifications", (modification != null ? Lists.newArrayList(modification) : Collections.emptyList())); addStatusMessages(model, modification); return ControllerConstants.Views.Fragments.Cart.AddToCartPopup; }
From source file:com.lixiaocong.rest.UserController.java
@RequestMapping(method = RequestMethod.PUT) public Map<String, Object> put(@RequestBody @Valid UserUpdateForm userUpdateForm, BindingResult result, Principal principal) throws RestParamException { if (result.hasErrors()) throw new RestParamException(); User user = userService.getByUsername(principal.getName()); user.setPassword(this.encoder.encode(userUpdateForm.getPassword())); userService.update(user);// w w w.java 2s . c o m return ResponseMsgFactory.createSuccessResponse(); }
From source file:forum.controller.UserController.java
@RequestMapping(value = "/inscription", method = RequestMethod.POST) public String inscription(@Valid @ModelAttribute("util") Utilisateur u, BindingResult result, HttpSession session, Model model) { if (result.hasErrors()) { List<Utilisateur.TypeConnexion> typeList = new ArrayList<>(2); typeList.add(Utilisateur.TypeConnexion.PREMIUM); typeList.add(Utilisateur.TypeConnexion.UTILISATEUR); model.addAttribute("typeList", typeList); return "user/user_inscription"; }/* w w w.j a v a2 s . c om*/ userService.save(u); session.setAttribute("isLogged", true); session.setAttribute("userLogin", u.getLogin()); return "redirect:/"; }
From source file:org.parancoe.basicwebappevolution.controllers.PersonController.java
@RequestMapping(method = { RequestMethod.PUT, RequestMethod.POST }) public String store(@ModelAttribute("person") @Valid Person person, BindingResult result, SessionStatus status, HttpServletRequest req) {//from w w w . j a v a 2 s. c o m if (result.hasErrors()) { return "person/edit"; } else { personDao.store(person); status.setComplete(); logger.info("Stored the person (" + person + ")"); FlashHelper.setRedirectNotice(req, "The person data have been stored."); return "redirect:"; } }
From source file:com.github.carlomicieli.nerdmovies.controllers.MovieController.java
@RequestMapping(value = "/{movie}/update", method = RequestMethod.POST) public String update(@Valid @ModelAttribute Movie movie, @RequestParam("file") MultipartFile file, BindingResult result) throws IOException { if (result.hasErrors()) { return "movie/edit"; }/*from w w w .j a v a2 s . c o m*/ if (!file.isEmpty()) { movie.setPoster(convert(file)); movie.setThumb(createThumbnail(file, 100)); } movieService.save(movie); return "redirect:../../movies"; }
From source file:com.github.carlomicieli.nerdmovies.controllers.ShowController.java
@RequestMapping(value = "/shows/create", method = RequestMethod.POST) public String save(@Valid ShowForm showForm, BindingResult bindingResults, Model model) { if (bindingResults.hasErrors()) { model.addAttribute(showForm);// w ww .jav a2 s.co m return "show/create"; } double[] location = null; try { location = locationService.findLocation(showForm.getGeocodingAddress()); } catch (Exception e) { e.printStackTrace(); } final Show show = new Show(); show.setHostedBy(securityService.getCurrentUser().getUsername()); show.setMovie(showForm.getMovie()); show.setDescription(showForm.getDescription()); show.setDate(showForm.getDate()); show.setAddress(showForm.getCompleteAddress()); show.setLocation(location[0], location[1]); showService.create(show); return "show/view"; }
From source file:mx.gob.cfe.documentos.web.FeligresController.java
@RequestMapping("/crea") public String crea(HttpServletRequest request, @Valid Feligres feligres, RedirectAttributes redirectAttributes, BindingResult bindingResult, Model model, Principal principal) { if (bindingResult.hasErrors()) { return "feligres/nuevo"; }//www. j a v a 2 s .c o m feligres.setFechaAlta(new Date()); feligres = instance.crea(feligres); redirectAttributes.addFlashAttribute("mensaje", "El feligres para " + feligres.getNombre() + "ha sido creado"); return "redirect:/feligres/ver/" + feligres.getId(); }
From source file:net.triptech.metahive.web.CategoryController.java
@RequestMapping(method = RequestMethod.POST) @PreAuthorize("hasRole('ROLE_ADMIN')") public String create(@Valid Category category, BindingResult bindingResult, Model uiModel, HttpServletRequest request) {/* w w w .j av a 2 s. c o m*/ if (bindingResult.hasErrors()) { uiModel.addAttribute("category", category); FlashScope.appendMessage(getMessage("metahive_object_validation", Category.class), request); return "categories/create"; } uiModel.asMap().clear(); category.persist(); category.flush(); FlashScope.appendMessage(getMessage("metahive_create_complete", Category.class), request); return "redirect:/lists"; }