Package org.springframework.validation

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


    TestBean tb = new TestBean();
    tb.setName("name1");
    Errors errors = new ServletRequestDataBinder(tb, "tb").getBindingResult();
    errors.rejectValue("name", "code1");
    errors.rejectValue("name", "code2");
    errors.rejectValue("age", "code2");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);

    BindTag tag = new BindTag();
    tag.setPageContext(pc);
    tag.setPath("tb.name");
View Full Code Here


  public void testBindTagWithFieldErrorsAndDefaultMessageOnly() throws JspException {
    PageContext pc = createPageContext();
    TestBean tb = new TestBean();
    tb.setName("name1");
    Errors errors = new ServletRequestDataBinder(tb, "tb").getBindingResult();
    errors.rejectValue("name", null, "message & 1");
    errors.rejectValue("name", null, "message2");
    errors.rejectValue("age", null, "message2");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);

    BindTag tag = new BindTag();
View Full Code Here

    PageContext pc = createPageContext();
    TestBean tb = new TestBean();
    tb.setName("name1");
    Errors errors = new ServletRequestDataBinder(tb, "tb").getBindingResult();
    errors.rejectValue("name", null, "message & 1");
    errors.rejectValue("name", null, "message2");
    errors.rejectValue("age", null, "message2");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);

    BindTag tag = new BindTag();
    tag.setPageContext(pc);
View Full Code Here

    TestBean tb = new TestBean();
    tb.setName("name1");
    Errors errors = new ServletRequestDataBinder(tb, "tb").getBindingResult();
    errors.rejectValue("name", null, "message & 1");
    errors.rejectValue("name", null, "message2");
    errors.rejectValue("age", null, "message2");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);

    BindTag tag = new BindTag();
    tag.setPageContext(pc);
    tag.setPath("tb.name");
View Full Code Here

    tb.setName("name1");
    TestBean spouse = new TestBean();
    spouse.setName("name2");
    tb.setSpouse(spouse);
    Errors errors = new ServletRequestDataBinder(tb, "tb").getBindingResult();
    errors.rejectValue("spouse.name", "code1", "message1");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);
    BindTag tag = new BindTag();
    tag.setPageContext(pc);
    pc.setAttribute("myattr", "tb.spouse.name");
    tag.setPath("${myattr}");
View Full Code Here

  public void testPropertyExposing() throws JspException {
    PageContext pc = createPageContext();
    TestBean tb = new TestBean();
    tb.setName("name1");
    Errors errors = new BindException(tb, "tb");
    errors.rejectValue("name", "code1", null, "message & 1");
    errors.rejectValue("name", "code2", null, "message2");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);

    // test global property (should be null)
    BindTag tag = new BindTag();
View Full Code Here

  public void testEscapedErrors() {
    TestBean tb = new TestBean();
    tb.setName("empty &");

    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());
View Full Code Here

    TestBean tb = new TestBean();
    tb.setName("empty &");

    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);
View Full Code Here

    tb.setName("empty &");

    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

  public void testBindTagWithFieldErrors() throws JspException {
    PageContext pc = createPageContext();
    TestBean tb = new TestBean();
    tb.setName("name1");
    Errors errors = new ServletRequestDataBinder(tb, "tb").getBindingResult();
    errors.rejectValue("name", "code1", "message & 1");
    errors.rejectValue("name", "code2", "message2");
    errors.rejectValue("age", "code2", "message2");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);

    BindTag tag = new BindTag();
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.