List of usage examples for org.springframework.validation BindingResult hasErrors
boolean hasErrors();
From source file:cz.muni.fi.mir.controllers.SourceDocumentController.java
@Secured("ROLE_USER") @RequestMapping(value = { "/create", "/create/" }, method = RequestMethod.POST) @SiteTitle("{navigation.sourcedocument.create}") public ModelAndView createSubmit( @Valid @ModelAttribute("sourceDocumentForm") SourceDocumentForm sourceDocumentForm, BindingResult result, Model model) { if (result.hasErrors()) { ModelMap mm = new ModelMap(); mm.addAttribute("soureDocumentForm", sourceDocumentForm); mm.addAttribute(model);// w w w. j av a 2s. co m return new ModelAndView("sourcedocument_create", mm); } else { sourceDocumentService.createSourceDocument(mapper.map(sourceDocumentForm, SourceDocument.class)); return new ModelAndView("redirect:/sourcedocument/list/"); } }
From source file:org.apache.shiro.samples.sprhib.web.SecurityController.java
@RequestMapping(value = "/login", method = RequestMethod.POST) public String login(Model model, @ModelAttribute LoginCommand command, BindingResult errors) { loginValidator.validate(command, errors); if (errors.hasErrors()) { return showLoginForm(model, command); }/*from ww w . ja v a2 s . com*/ UsernamePasswordToken token = new UsernamePasswordToken(command.getUsername(), command.getPassword(), command.isRememberMe()); try { SecurityUtils.getSubject().login(token); } catch (AuthenticationException e) { errors.reject("error.login.generic", "Invalid username or password. Please try again."); } if (errors.hasErrors()) { return showLoginForm(model, command); } else { return "redirect:/s/home"; } }
From source file:com.mitchellbosecke.pebble.spring.extension.function.bindingresult.HasErrorsFunction.java
@Override public Object execute(Map<String, Object> args) { String formName = (String) args.get(PARAM_FORM_NAME); EvaluationContext context = (EvaluationContext) args.get("_context"); BindingResult bindingResult = this.getBindingResult(formName, context); if (bindingResult != null) { return bindingResult.hasErrors(); } else {//from w w w .ja v a 2 s. co m return false; } }
From source file:com.springsource.greenhouse.develop.AppController.java
/** * Register a new application for the developer. *//*from ww w.j a v a2s. c om*/ @RequestMapping(value = "/develop/apps", method = RequestMethod.POST) public String create(@Valid AppForm form, BindingResult bindingResult, Account account) { if (bindingResult.hasErrors()) { return "develop/apps/new"; } return "redirect:/develop/apps/" + connectedAppRepository.createApp(account.getId(), form); }
From source file:com.springsource.oauthservice.develop.AppController.java
@RequestMapping(value = "/apps/{slug}", method = RequestMethod.PUT) public String update(@PathVariable String slug, @Valid AppForm form, BindingResult bindingResult, Principal user, Model model) { if (bindingResult.hasErrors()) { model.addAttribute("slug", slug); return "develop/apps/edit"; }/*from w ww. ja va 2s . c o m*/ return "redirect:/develop/apps/" + appRepository.updateApp(user.getName(), slug, form); }
From source file:cz.muni.fi.mir.controllers.SourceDocumentController.java
@Secured("ROLE_ADMINISTRATOR") @SiteTitle("{entity.sourceDocument.edit}") @RequestMapping(value = { "/edit", "/edit/" }, method = RequestMethod.POST) public ModelAndView editSourceDocumentSubmit( @Valid @ModelAttribute("sourceDocumentForm") SourceDocumentForm sourceDocumentForm, BindingResult result, Model model) { if (result.hasErrors()) { ModelMap mm = new ModelMap(); mm.addAttribute("sourceDocumentForm", sourceDocumentForm); mm.addAttribute(model);// w w w. j av a 2 s . c om return new ModelAndView("sourcedocument_edit", mm); } else { sourceDocumentService.updateSourceDocument(mapper.map(sourceDocumentForm, SourceDocument.class)); return new ModelAndView("redirect:/sourcedocument/list/"); } }
From source file:nl.enovation.addressbook.jpa.webui.controller.ContactsController.java
@RequestMapping(value = "new", method = RequestMethod.POST) public String formNewSubmit(@Valid Contact contact, BindingResult bindingResult) { if (bindingResult.hasErrors()) { return "contacts/new"; }//from w w w . ja va 2 s . co m contactRepository.save(contact); return "redirect:/contacts/" + contact.getIdentifier(); }
From source file:com.gym.controller.UsuarioController.java
@RequestMapping(value = "/login", method = RequestMethod.POST) public String login(Map<String, Object> map, HttpServletRequest request, @Valid AccesoUsuario accesoUsuario, BindingResult result) { if (result.hasErrors()) { return "index"; }/*from w w w.j a va2s .c o m*/ AccesoUsuario accesoOK = accesoUsuarioService.getAccesoUsuario(accesoUsuario.getLogin(), accesoUsuario.getPassword()); if (accesoOK == null) { map.put("error", "error"); return "index"; } else { HttpSession misesion = request.getSession(); misesion.setAttribute("accesoUsuario", accesoOK); return "redirect:./inicio"; } }
From source file:nl.enovation.addressbook.jpa.webui.controller.ContactsController.java
@RequestMapping(value = "search", method = RequestMethod.POST) public String search(@ModelAttribute("searchForm") SearchForm value, Model model, BindingResult bindingResult) { if (bindingResult.hasErrors()) { return "contacts/list"; }// w ww. jav a2 s . co m List<Contact> listSearchContacts = contactRepository.findByName(value.getSearchValue()); model.addAttribute("contacts", listSearchContacts); return "contacts/list"; }
From source file:org.perconsys.controllers.AuthController.java
@RequestMapping(value = "/register", method = RequestMethod.POST) public String registerHandler(@Valid @ModelAttribute("user") User user, BindingResult result, HttpServletRequest request) {/* w w w. j a va 2 s . co m*/ if (result.hasErrors()) { return "auth/reg_form"; } user = dao.add(user); setToSession("user", user); return "auth/reg_result"; }