Package org.springframework.validation

Examples of org.springframework.validation.Errors.reject()


    Errors errors = new EscapedErrors(new BindException(tb, "tb"));
    errors.rejectValue("name", "NAME_EMPTY &", null, "message: &");
    errors.rejectValue("age", "AGE_NOT_SET <tag>", null, "message: <tag>");
    errors.rejectValue("age", "AGE_NOT_32 <tag>", null, "message: <tag>");
    errors.reject("GENERAL_ERROR \" '", null, "message: \" '");

    assertTrue("Correct errors flag", errors.hasErrors());
    assertTrue("Correct number of errors", errors.getErrorCount() == 4);
    assertTrue("Correct object name", "tb".equals(errors.getObjectName()));
View Full Code Here


   * http://opensource.atlassian.com/projects/spring/browse/SPR-4005
   */
  public void testOmittedPathMatchesObjectErrorsOnly() throws Exception {
    this.tag.setPath(null);
    Errors errors = new BeanPropertyBindingResult(new TestBean(), "COMMAND_NAME");
    errors.reject("some.code", "object error");
    errors.rejectValue("name", "some.code", "field error");
    exposeBindingResult(errors);
    this.tag.doStartTag();
    assertNotNull(getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE));
    this.tag.doEndTag();
View Full Code Here

  }

  public void testSpecificPathMatchesSpecificFieldOnly() throws Exception {
    this.tag.setPath("name");
    Errors errors = new BeanPropertyBindingResult(new TestBean(), "COMMAND_NAME");
    errors.reject("some.code", "object error");
    errors.rejectValue("name", "some.code", "field error");
    exposeBindingResult(errors);
    this.tag.doStartTag();
    assertNotNull(getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE));
    this.tag.doEndTag();
View Full Code Here

  }

  public void testStarMatchesAllErrors() throws Exception {
    this.tag.setPath("*");
    Errors errors = new BeanPropertyBindingResult(new TestBean(), "COMMAND_NAME");
    errors.reject("some.code", "object error");
    errors.rejectValue("name", "some.code", "field error");
    exposeBindingResult(errors);
    this.tag.doStartTag();
    assertNotNull(getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE));
    this.tag.doEndTag();
View Full Code Here

          favoriteAdd(user, tag);
        } else {
          ignoreAdd(user, tag);
        }
      } catch (TagNotFoundException e) {
        errors.reject(e.getMessage() + ": '" + tag + '\'');
      } catch (DuplicateKeyException e) {
        errors.reject("Тег уже добавлен: '" + tag);
      }
    }
    return errorsToStringList(errors);
View Full Code Here

          ignoreAdd(user, tag);
        }
      } catch (TagNotFoundException e) {
        errors.reject(e.getMessage() + ": '" + tag + '\'');
      } catch (DuplicateKeyException e) {
        errors.reject("Тег уже добавлен: '" + tag);
      }
    }
    return errorsToStringList(errors);
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.