Package org.springframework.validation

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


    MockRequestContext context = new MockRequestContext(parameters());

    assertEquals(action.getEventFactorySupport().getSuccessEventId(), action.setupForm(context).getId());

    Errors errors = getErrors(context);
    errors.reject("dummy");
    TestBean formObject = getFormObject(context);
    formObject.setProp("bla");

    // setupForm() should leave the existing form object and Errors instance
    // untouched, at least when no bind & validate is done (bindOnSetupForm
View Full Code Here


    MockRequestContext context = new MockRequestContext(parameters());

    assertEquals(action.getEventFactorySupport().getSuccessEventId(), action.setupForm(context).getId());

    Errors errors = getErrors(context);
    errors.reject("dummy");
    TestBean formObject = getFormObject(context);
    formObject.setProp("bla");

    // bindAndValidate() should leave the existing form object untouched
    // but should setup a new Errors instance during bind & validate
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 testBindErrorsTagWithErrors() throws JspException {
    PageContext pc = createPageContext();
    Errors errors = new ServletRequestDataBinder(new TestBean(), "tb").getBindingResult();
    errors.reject("test", null, "test");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);
    BindErrorsTag tag = new BindErrorsTag();
    tag.setPageContext(pc);
    tag.setName("tb");
    assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
View Full Code Here

  }

  public void testBindTagWithGlobalErrors() throws JspException {
    PageContext pc = createPageContext();
    Errors errors = new ServletRequestDataBinder(new TestBean(), "tb").getBindingResult();
    errors.reject("code1", "message1");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);

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

  }

  public void testBindTagWithGlobalErrorsAndNoDefaultMessage() throws JspException {
    PageContext pc = createPageContext();
    Errors errors = new ServletRequestDataBinder(new TestBean(), "tb").getBindingResult();
    errors.reject("code1");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);

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

  }

  public void testBindTagWithGlobalErrorsAndDefaultMessageOnly() throws JspException {
    PageContext pc = createPageContext();
    Errors errors = new ServletRequestDataBinder(new TestBean(), "tb").getBindingResult();
    errors.reject(null, "message1");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);

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

  public void testBindStatusGetErrorMessagesAsString() throws JspException {
    // one error (should not include delimiter)
    PageContext pc = createPageContext();
    Errors errors = new ServletRequestDataBinder(new TestBean(), "tb").getBindingResult();
    errors.reject("code1", null, "message1");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);
    BindTag tag = new BindTag();
    tag.setPageContext(pc);
    tag.setPath("tb");
    tag.doStartTag();
View Full Code Here

        status.getErrorMessagesAsString(","), "message1");

    // two errors
    pc = createPageContext();
    errors = new ServletRequestDataBinder(new TestBean(), "tb").getBindingResult();
    errors.reject("code1", null, "message1");
    errors.reject("code1", null, "message2");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);
    tag = new BindTag();
    tag.setPageContext(pc);
    tag.setPath("tb");
View Full Code Here

    // two errors
    pc = createPageContext();
    errors = new ServletRequestDataBinder(new TestBean(), "tb").getBindingResult();
    errors.reject("code1", null, "message1");
    errors.reject("code1", null, "message2");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);
    tag = new BindTag();
    tag.setPageContext(pc);
    tag.setPath("tb");
    tag.doStartTag();
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.