Package org.springframework.validation

Examples of org.springframework.validation.ObjectError


       
    newUser.setUsername(username);
    newUser.setPassword(password);
    newUser.setConfirmPassword(confirmPassword);
   
    errorList.add(new ObjectError("confirmPassword.mismatch", "Password mismatch"));
   
    expect(errors.hasErrors()).andReturn(true).anyTimes();   
    expect(errors.getAllErrors()).andReturn(errorList).anyTimes();
    replay(errors);
    replay(model);
View Full Code Here


       
    newUser.setUsername(username);
    newUser.setPassword(password);
    newUser.setConfirmPassword(confirmPassword);
   
    errorList.add(new ObjectError("confirmPassword.mismatch", "Password mismatch"));
   
    expect(errors.hasErrors()).andReturn(true).anyTimes();   
    expect(errors.getAllErrors()).andReturn(errorList).anyTimes();
    replay(errors);
        replay(model);
View Full Code Here

       
    newUser.setUsername(username);
    newUser.setPassword(password);
    newUser.setConfirmPassword(confirmPassword);
   
    errorList.add(new ObjectError("username.required", "Username required"));
    errorList.add(new ObjectError("password.required", "Password required"));
    errorList.add(new ObjectError("confirmPassword.required", "Confirm password required"));
   
    expect(errors.hasErrors()).andReturn(true).anyTimes();   
    expect(errors.getAllErrors()).andReturn(errorList).anyTimes();
    replay(errors);
View Full Code Here

   * Extract the error codes from the ObjectError list.
   */
  private void initErrorCodes() {
    this.errorCodes = new String[this.objectErrors.size()];
    for (int i = 0; i < this.objectErrors.size(); i++) {
      ObjectError error = (ObjectError) this.objectErrors.get(i);
      this.errorCodes[i] = error.getCode();
    }
  }
View Full Code Here

   */
  private void initErrorMessages() throws NoSuchMessageException {
    if (this.errorMessages == null) {
      this.errorMessages = new String[this.objectErrors.size()];
      for (int i = 0; i < this.objectErrors.size(); i++) {
        ObjectError error = (ObjectError) this.objectErrors.get(i);
        this.errorMessages[i] = this.requestContext.getMessage(error, this.htmlEscape);
      }
    }
  }
View Full Code Here

            // can do custom FieldError registration with invalid value from ConstraintViolation,
            // as necessary for Hibernate Validator compatibility (non-indexed set path in field)
            BindingResult bindingResult = (BindingResult) errors;
            String[] errorCodes = bindingResult.resolveMessageCodes(errorCode, field);
            String nestedField = bindingResult.getNestedPath() + field;
            ObjectError error;
            if ("".equals(nestedField)) {
              error = new ObjectError(
                  errors.getObjectName(), errorCodes, errorArgs, violation.getMessage());
            }
            else {
              Object invalidValue = violation.getInvalidValue();
              if (!"".equals(field) && invalidValue == violation.getLeafBean()) {
View Full Code Here

            // as necessary for Hibernate Validator compatibility (non-indexed set path in field)
            BindingResult bindingResult = (BindingResult) errors;
            String nestedField = bindingResult.getNestedPath() + field;
            if ("".equals(nestedField)) {
              String[] errorCodes = bindingResult.resolveMessageCodes(errorCode);
              bindingResult.addError(new ObjectError(
                  errors.getObjectName(), errorCodes, errorArgs, violation.getMessage()));
            }
            else {
              Object invalidValue = violation.getInvalidValue();
              if (!"".equals(field) && invalidValue == violation.getLeafBean()) {
View Full Code Here

   */
  private ActionMessages getActionMessages() {
    ActionMessages actionMessages = new ActionMessages();
    Iterator it = this.errors.getAllErrors().iterator();
    while (it.hasNext()) {
      ObjectError objectError = (ObjectError) it.next();
      String effectiveMessageKey = findEffectiveMessageKey(objectError);
      if (effectiveMessageKey == null && !defaultActionMessageAvailable) {
        // Need to specify default code despite it not being resolvable:
        // Struts 1.1 ActionMessage doesn't support default messages.
        effectiveMessageKey = objectError.getCode();
      }
      ActionMessage message = (effectiveMessageKey != null) ?
          new ActionMessage(effectiveMessageKey, resolveArguments(objectError.getArguments())) :
          new ActionMessage(objectError.getDefaultMessage(), false);
      if (objectError instanceof FieldError) {
        FieldError fieldError = (FieldError) objectError;
        actionMessages.add(fieldError.getField(), message);
      }
      else {
View Full Code Here

   * Extract the error codes from the ObjectError list.
   */
  private void initErrorCodes() {
    this.errorCodes = new String[this.objectErrors.size()];
    for (int i = 0; i < this.objectErrors.size(); i++) {
      ObjectError error = (ObjectError) this.objectErrors.get(i);
      this.errorCodes[i] = error.getCode();
    }
  }
View Full Code Here

   */
  private void initErrorMessages() throws NoSuchMessageException {
    if (this.errorMessages == null) {
      this.errorMessages = new String[this.objectErrors.size()];
      for (int i = 0; i < this.objectErrors.size(); i++) {
        ObjectError error = (ObjectError) this.objectErrors.get(i);
        this.errorMessages[i] = this.requestContext.getMessage(error, this.htmlEscape);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.springframework.validation.ObjectError

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.