List of usage examples for org.springframework.validation BindingResult hasErrors
boolean hasErrors();
From source file:nl.enovation.addressbook.cqrs.webui.controllers.ContactsController.java
@RequestMapping(value = "new", method = RequestMethod.POST) public String formNewSubmit(@ModelAttribute("contact") @Valid ContactEntry contact, BindingResult bindingResult) { if (bindingResult.hasErrors()) { return "contacts/new"; }/* www .j av a 2 s . c o m*/ AbstractContactCrudCommand command = new CreateContactCommand(new UUIDAggregateIdentifier(), contact); LOGGER.debug("Dispatching command with name : {}", command.toString()); commandBus.dispatch(command); return "redirect:/contacts/" + contact.getIdentifier(); }
From source file:technology.tikal.ventas.service.catalogo.ProductoService.java
@RequestMapping(produces = "application/json;charset=UTF-8", method = RequestMethod.GET) public Page<Producto[]> consultar(@PathVariable final Long idCatalogo, @Valid @ModelAttribute final PaginationDataLong pagination, final BindingResult resultPagination, final HttpServletRequest httpRequest) { if (resultPagination.hasErrors()) { throw new NotValidException(resultPagination); }/* w ww . java2 s . com*/ Page<Producto[]> r = PaginationModelFactory.getPage(productoController.consultar(idCatalogo, pagination), "Pedido", httpRequest.getRequestURI(), null, pagination); return r; }
From source file:technology.tikal.ventas.service.envio.EnvioService.java
@RequestMapping(produces = "application/json;charset=UTF-8", method = RequestMethod.GET) public Page<Envio[]> consultar(@PathVariable final Long pedidoId, @Valid @ModelAttribute final PaginationDataLong pagination, final BindingResult resultPagination, final HttpServletRequest httpRequest) { if (resultPagination.hasErrors()) { throw new NotValidException(resultPagination); }/* w w w .ja va 2 s . co m*/ Page<Envio[]> r = PaginationModelFactory.getPage(envioController.consultar(pedidoId, pagination), "Envio", httpRequest.getRequestURI(), null, pagination); return r; }
From source file:technology.tikal.ventas.service.pedido.PartidaService.java
@RequestMapping(produces = "application/json;charset=UTF-8", method = RequestMethod.GET) public Page<Partida[]> consultar(@PathVariable final Long pedidoId, @Valid @ModelAttribute final PaginationDataLong pagination, final BindingResult resultPagination, final HttpServletRequest httpRequest) { if (resultPagination.hasErrors()) { throw new NotValidException(resultPagination); }/* w w w .ja va2 s .c om*/ Page<Partida[]> r = PaginationModelFactory.getPage(partidaController.consultar(pedidoId, pagination), "Pedido", httpRequest.getRequestURI(), null, pagination); return r; }
From source file:technology.tikal.ventas.service.pedido.SubPedidoService.java
@RequestMapping(produces = "application/json;charset=UTF-8", method = RequestMethod.GET) public Page<SubPedido[]> consultar(@PathVariable final Long pedidoId, @Valid @ModelAttribute final PaginationDataLong pagination, final BindingResult resultPagination, final HttpServletRequest httpRequest) { if (resultPagination.hasErrors()) { throw new NotValidException(resultPagination); }/*from ww w . j a v a 2 s . c o m*/ Page<SubPedido[]> r = PaginationModelFactory.getPage(subPedidoController.consultar(pedidoId, pagination), "Pedido", httpRequest.getRequestURI(), null, pagination); return r; }
From source file:cherry.sqlman.tool.password.PasswordChangeControllerImpl.java
private boolean hasErrors(PasswordChangeForm form, BindingResult binding) { // ??//from w w w .jav a2 s .c om if (binding.hasErrors()) { return true; } // ? if (!StringUtils.equals(form.getPassword(), form.getPasswordConf())) { LogicalErrorUtil.rejectValue(binding, PasswordChangeFormBase.Prop.PasswordConf.getName(), LogicError.PasswordConfUnmatch); return true; } // ?? return false; }
From source file:com.dub.skoolie.web.controller.system.district.SystemDistrictController.java
@RequestMapping(value = "/system/districts", method = RequestMethod.POST) public ModelAndView addDistrict(@Valid DistrictBean districtBean, BindingResult result, Model model, HttpServletRequest request) {/* ww w . j a va 2 s . com*/ String referrer = request.getHeader("Referer"); if (result.hasErrors()) { if (!referrer.equals("/system/districts")) { return new ModelAndView("redirect:" + referrer); } model.addAttribute("districtBean", districtBean); model.addAttribute("districts", uiDistrictServiceImpl.getDistricts()); return new ModelAndView("system/district/districts"); } uiDistrictServiceImpl.addDistrict(districtBean); return new ModelAndView("redirect:" + referrer); }
From source file:com.swcguild.addressbookmvc.controller.HomeControllerNoAjax.java
@RequestMapping(value = "/addNewContactNoAjax", method = RequestMethod.POST) public String addNewContactNoAjax(@Valid Contact contact, BindingResult result, HttpServletRequest req) { if (result.hasErrors()) { return "newContactFormNoAjax"; }/*w w w. ja v a 2s. co m*/ String firstName = req.getParameter("firstName"); String lastName = req.getParameter("lastName"); String street = req.getParameter("street"); String city = req.getParameter("city"); String state = req.getParameter("state"); String zip = req.getParameter("zip"); contact = new Contact(); contact.setFirstName(firstName); contact.setLastName(lastName); contact.setStreet(street); contact.setCity(city); contact.setState(state); contact.setZip(zip); dao.addContact(contact); return "redirect:displayAddressBookNoAjax"; }
From source file:com.tsg.addressbookmvc.HomeControllerNoAjax.java
@RequestMapping(value = "/addNewAddressFormNoAjax", method = RequestMethod.POST) public String addNewAddressNoAjax(@Valid @ModelAttribute("address") Address address, BindingResult result) { if (result.hasErrors()) { return "newAddressFormNoAjax"; }/*from www . j a v a2s . co m*/ // below are not needed with new funtionality, kept as a reference // <-- Get all of the form data from the request --> // String firstName = req.getParameter("firstName"); // String lastName = req.getParameter("lastName"); // String address = req.getParameter("address"); // String city = req.getParameter("city"); // String state = req.getParameter("state"); // String zipCode = req.getParameter("zipCode"); // // <--Create a new Contact and set all the fields--> // Address address1 = new Address(); // address1.setFirstName(firstName); // address1.setLastName(lastName); // address1.setAddress(address); // address1.setCity(city); // address1.setState(state); // address1.setZipCode(zipCode); // // Add the Address to the DAO dao.addAddress(address); // Redirect to the displayAddressListNoAjax controller endpoint - we must // use the redirect: here so that Spring MVC routes us to the controller // endpoint and not directly to a JSP. return "redirect:displayAddressListNoAjax"; }
From source file:com.wiiyaya.consumer.web.main.controller.UserController.java
@RequestMapping(value = MainURIResource.PATH_SYS_USER_ADD, method = { RequestMethod.POST }) @ResponseBody/*from www. j a v a2 s . c om*/ public void add( @Validated @ModelAttribute(MainURIResource.MODEL_BACKEND_USER_DTO) BackendUserDto backendUserDto, BindingResult result) throws BusinessException, ValidateException { if (result.hasErrors()) { throw new ValidateException(result.getFieldError().getObjectName(), result.getFieldError().getField(), result.getFieldError().getDefaultMessage()); } backendUserService.saveUser(backendUserDto); }