Package org.springframework.validation

Examples of org.springframework.validation.FieldError


      HttpHeaders headers, HttpStatus status, WebRequest request) {
    List<ObjectError> errorList = ex.getAllErrors();
    StringBuilder msg = new StringBuilder();
    for (ObjectError error : errorList) {
      if (error instanceof FieldError) {
        FieldError fieldError = (FieldError)error;
        msg.append(fieldError.getField() + "字段、");
      } else {
        msg.append(error.getObjectName() + "对象、");
      }
     
      LOGGER.error(error + Exceptions.getStackTraceAsString(ex));
View Full Code Here


        modelAndView.addObject("loginUrl", getLoginUrl(request));
        return modelAndView;
    }

    private static FieldError createEmailExistsError(String email) {
        return new FieldError(RegistrationFormBean.class.getName(), "email",
            email, false, new String[] { EMAIL_EXISTS_ERROR_CODE },
            null, EMAIL_EXISTS_DEFAULT_MESSAGE);
    }
View Full Code Here

    mps.addFirst(new MapPropertySource("options", (Map) raw));
    try {
      dataBinder.bind(new PropertySourcesPropertyValues(mps));
    }
    catch (InvalidPropertyException e) {
      dataBinder.getBindingResult().addError(new FieldError("options", e.getPropertyName(), e.getMessage()));
    }

    CustomValidatorBean validator = new CustomValidatorBean();
    validator.afterPropertiesSet();
    dataBinder.setValidator(validator);
View Full Code Here


    for (String key : raw.keySet()) {
      int separator = key.indexOf(OPTION_SEPARATOR);
      if (separator == -1) {
        bindingResult.addError(new FieldError("options", key, String.format("unsupported option '%s'", key)));
        continue;
      }
      String prefix = key.substring(0, separator);
      String suffix = key.substring(separator + OPTION_SEPARATOR.length());
      Map<String, String> map = valuesWithoutPrefix.get(prefix);
      if (map == null) {
        bindingResult.addError(new FieldError("options", key, String.format("unsupported option '%s'", key)));
        continue;
      }
      map.put(suffix, raw.get(key));
    }
View Full Code Here

    if (copy.size() > 0) {
      // We're just interested in a container for errors
      BindingResult bindingResult = new MapBindingResult(new HashMap<String, Object>(), "flattened");
      for (String pty : copy.keySet()) {
        bindingResult.addError(new FieldError("flattened", pty, String.format(
            "option named '%s' is not supported", pty)));
      }
      throw new BindException(bindingResult);
    }
View Full Code Here

  @Override
  public ModuleOptions interpolate(final Map<String, String> raw) throws BindException {
    MapBindingResult bindingResult = new MapBindingResult(new HashMap<String, String>(), "options");
    for (String provided : raw.keySet()) {
      if (!options.containsKey(provided)) {
        bindingResult.addError(new FieldError("options", provided, String.format(
            "Module option '%s' does not exist", provided)));
      }
    }

    if (bindingResult.hasErrors()) {
View Full Code Here

        }
        try {
            userService.restorePassword(dto.getUserEmail());
            mav.addObject("message", "label.restorePassword.completed");
        } catch (MailingFailedException e) {
            result.addError(new FieldError("dto", "email", "email.failed"));
        }
        return mav;
    }
View Full Code Here

    BindingResult br = new TestBindingResult(Collections.<FieldError> emptyList());
    ExtDirectFormPostResult result = new ExtDirectFormPostResult(br);
    assertThat(result.getResult()).hasSize(1).contains(
        MapEntry.entry("success", Boolean.TRUE));

    FieldError error = new FieldError("testobject", "field1", "message");
    br = new TestBindingResult(Collections.singletonList(error));
    result = new ExtDirectFormPostResult(br);
    assertThat(result.getResult()).hasSize(2).contains(
        MapEntry.entry("success", Boolean.FALSE));
    Map<String, List<String>> errors = (Map<String, List<String>>) result.getResult()
View Full Code Here

    BindingResult br = new TestBindingResult(Collections.<FieldError> emptyList());
    ExtDirectFormPostResult result = new ExtDirectFormPostResult(br, false);
    assertThat(result.getResult()).hasSize(1).contains(
        MapEntry.entry("success", Boolean.FALSE));

    br = new TestBindingResult(Arrays.asList(new FieldError("testobject", "field1",
        "message"), new FieldError("testobject", "field2", "second message")));
    result = new ExtDirectFormPostResult(br, true);
    assertThat(result.getResult()).hasSize(2).contains(
        MapEntry.entry("success", Boolean.TRUE));
    Map<String, List<String>> errors = (Map<String, List<String>>) result.getResult()
        .get("errors");
View Full Code Here

                "Adding field error object's: {} field: {} with error code: {}",
                objectName,
                fieldName,
                errorCode
        );
        FieldError error = new FieldError(
                objectName,
                fieldName,
                fieldValue,
                false,
                new String[]{errorCode},
View Full Code Here

TOP

Related Classes of org.springframework.validation.FieldError

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.