congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
ErrorsTag.doEndTag
Code IndexAdd Tabnine to your IDE (free)

How to use
doEndTag
method
in
org.springframework.web.servlet.tags.form.ErrorsTag

Best Java code snippets using org.springframework.web.servlet.tags.form.ErrorsTag.doEndTag (Showing top 19 results out of 315)

origin: spring-projects/spring-framework

@Test
public void withoutErrorsInstance() throws Exception {
  int result = this.tag.doStartTag();
  assertEquals(Tag.SKIP_BODY, result);
  result = this.tag.doEndTag();
  assertEquals(Tag.EVAL_PAGE, result);
  String output = getOutput();
  assertEquals(0, output.length());
}
origin: spring-projects/spring-framework

@Test
public void withoutErrors() throws Exception {
  Errors errors = new BeanPropertyBindingResult(new TestBean(), "COMMAND_NAME");
  exposeBindingResult(errors);
  int result = this.tag.doStartTag();
  assertEquals(Tag.SKIP_BODY, result);
  result = this.tag.doEndTag();
  assertEquals(Tag.EVAL_PAGE, result);
  String output = getOutput();
  assertEquals(0, output.length());
}
origin: spring-projects/spring-framework

@Test
public void specificPathMatchesSpecificFieldOnly() 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();
  String output = getOutput();
  assertTrue(output.contains("id=\"name.errors\""));
  assertFalse(output.contains("object error"));
  assertTrue(output.contains("field error"));
}
origin: spring-projects/spring-framework

@Test
public void starMatchesAllErrors() 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();
  String output = getOutput();
  assertTrue(output.contains("id=\"testBean.errors\""));
  assertTrue(output.contains("object error"));
  assertTrue(output.contains("field error"));
}
origin: spring-projects/spring-framework

/**
 * https://jira.spring.io/browse/SPR-4005
 */
@Test
public void omittedPathMatchesObjectErrorsOnly() 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();
  String output = getOutput();
  assertTrue(output.contains("id=\"testBean.errors\""));
  assertTrue(output.contains("object error"));
  assertFalse(output.contains("field error"));
}
origin: spring-projects/spring-framework

private void assertWhenNoErrorsExistingMessagesInScopeAreNotClobbered(int scope) throws JspException {
  String existingAttribute = "something";
  getPageContext().setAttribute(ErrorsTag.MESSAGES_ATTRIBUTE, existingAttribute, scope);
  Errors errors = new BeanPropertyBindingResult(new TestBean(), "COMMAND_NAME");
  exposeBindingResult(errors);
  int result = this.tag.doStartTag();
  assertEquals(Tag.SKIP_BODY, result);
  result = this.tag.doEndTag();
  assertEquals(Tag.EVAL_PAGE, result);
  String output = getOutput();
  assertEquals(0, output.length());
  assertEquals(existingAttribute, getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE, scope));
}
origin: spring-projects/spring-framework

@Test
public void withExplicitNonWhitespaceBodyContent() throws Exception {
  String mockContent = "This is some explicit body content";
  this.tag.setBodyContent(new MockBodyContent(mockContent, getWriter()));
  // construct an errors instance of the tag
  TestBean target = new TestBean();
  target.setName("Rob Harrop");
  Errors errors = new BeanPropertyBindingResult(target, COMMAND_NAME);
  errors.rejectValue("name", "some.code", "Default Message");
  exposeBindingResult(errors);
  int result = this.tag.doStartTag();
  assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
  result = this.tag.doEndTag();
  assertEquals(Tag.EVAL_PAGE, result);
  assertEquals(mockContent, getOutput());
}
origin: spring-projects/spring-framework

@Test
public void withExplicitEmptyWhitespaceBodyContent() throws Exception {
  this.tag.setBodyContent(new MockBodyContent("", getWriter()));
  // construct an errors instance of the tag
  TestBean target = new TestBean();
  target.setName("Rob Harrop");
  Errors errors = new BeanPropertyBindingResult(target, COMMAND_NAME);
  errors.rejectValue("name", "some.code", "Default Message");
  exposeBindingResult(errors);
  int result = this.tag.doStartTag();
  assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
  result = this.tag.doEndTag();
  assertEquals(Tag.EVAL_PAGE, result);
  String output = getOutput();
  assertElementTagOpened(output);
  assertElementTagClosed(output);
  assertContainsAttribute(output, "id", "name.errors");
  assertBlockTagContains(output, "Default Message");
}
origin: spring-projects/spring-framework

@Test
public void withEscapedErrors() throws Exception {
  // construct an errors instance of the tag
  TestBean target = new TestBean();
  target.setName("Rob Harrop");
  Errors errors = new BeanPropertyBindingResult(target, COMMAND_NAME);
  errors.rejectValue("name", "some.code", "Default <> Message");
  errors.rejectValue("name", "too.short", "Too & Short");
  exposeBindingResult(errors);
  int result = this.tag.doStartTag();
  assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
  result = this.tag.doEndTag();
  assertEquals(Tag.EVAL_PAGE, result);
  String output = getOutput();
  assertElementTagOpened(output);
  assertElementTagClosed(output);
  assertContainsAttribute(output, "id", "name.errors");
  assertBlockTagContains(output, "<br/>");
  assertBlockTagContains(output, "Default &lt;&gt; Message");
  assertBlockTagContains(output, "Too &amp; Short");
}
origin: spring-projects/spring-framework

@Test
public void withExplicitWhitespaceBodyContent() throws Exception {
  this.tag.setBodyContent(new MockBodyContent("\t\n   ", getWriter()));
  // construct an errors instance of the tag
  TestBean target = new TestBean();
  target.setName("Rob Harrop");
  Errors errors = new BeanPropertyBindingResult(target, COMMAND_NAME);
  errors.rejectValue("name", "some.code", "Default Message");
  exposeBindingResult(errors);
  int result = this.tag.doStartTag();
  assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
  result = this.tag.doEndTag();
  assertEquals(Tag.EVAL_PAGE, result);
  String output = getOutput();
  assertElementTagOpened(output);
  assertElementTagClosed(output);
  assertContainsAttribute(output, "id", "name.errors");
  assertBlockTagContains(output, "Default Message");
}
origin: spring-projects/spring-framework

@Test
public void withErrors() throws Exception {
  // construct an errors instance of the tag
  TestBean target = new TestBean();
  target.setName("Rob Harrop");
  Errors errors = new BeanPropertyBindingResult(target, COMMAND_NAME);
  errors.rejectValue("name", "some.code", "Default Message");
  errors.rejectValue("name", "too.short", "Too Short");
  exposeBindingResult(errors);
  int result = this.tag.doStartTag();
  assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
  result = this.tag.doEndTag();
  assertEquals(Tag.EVAL_PAGE, result);
  String output = getOutput();
  assertElementTagOpened(output);
  assertElementTagClosed(output);
  assertContainsAttribute(output, "id", "name.errors");
  assertBlockTagContains(output, "<br/>");
  assertBlockTagContains(output, "Default Message");
  assertBlockTagContains(output, "Too Short");
}
origin: spring-projects/spring-framework

@Test
public void withNonEscapedErrors() throws Exception {
  this.tag.setHtmlEscape(false);
  // construct an errors instance of the tag
  TestBean target = new TestBean();
  target.setName("Rob Harrop");
  Errors errors = new BeanPropertyBindingResult(target, COMMAND_NAME);
  errors.rejectValue("name", "some.code", "Default <> Message");
  errors.rejectValue("name", "too.short", "Too & Short");
  exposeBindingResult(errors);
  int result = this.tag.doStartTag();
  assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
  result = this.tag.doEndTag();
  assertEquals(Tag.EVAL_PAGE, result);
  String output = getOutput();
  assertElementTagOpened(output);
  assertElementTagClosed(output);
  assertContainsAttribute(output, "id", "name.errors");
  assertBlockTagContains(output, "<br/>");
  assertBlockTagContains(output, "Default <> Message");
  assertBlockTagContains(output, "Too & Short");
}
origin: spring-projects/spring-framework

@Test
public void withErrorsAndCustomElement() throws Exception {
  // construct an errors instance of the tag
  TestBean target = new TestBean();
  target.setName("Rob Harrop");
  Errors errors = new BeanPropertyBindingResult(target, COMMAND_NAME);
  errors.rejectValue("name", "some.code", "Default Message");
  errors.rejectValue("name", "too.short", "Too Short");
  exposeBindingResult(errors);
  this.tag.setElement("div");
  int result = this.tag.doStartTag();
  assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
  result = this.tag.doEndTag();
  assertEquals(Tag.EVAL_PAGE, result);
  String output = getOutput();
  assertElementTagOpened(output);
  assertElementTagClosed(output);
  assertContainsAttribute(output, "id", "name.errors");
  assertBlockTagContains(output, "<br/>");
  assertBlockTagContains(output, "Default Message");
  assertBlockTagContains(output, "Too Short");
}
origin: spring-projects/spring-framework

@Test
public void asBodyTag() throws Exception {
  Errors errors = new BeanPropertyBindingResult(new TestBean(), "COMMAND_NAME");
  errors.rejectValue("name", "some.code", "Default Message");
  errors.rejectValue("name", "too.short", "Too Short");
  exposeBindingResult(errors);
  int result = this.tag.doStartTag();
  assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
  assertNotNull(getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE));
  String bodyContent = "Foo";
  this.tag.setBodyContent(new MockBodyContent(bodyContent, getWriter()));
  this.tag.doEndTag();
  this.tag.doFinally();
  assertEquals(bodyContent, getOutput());
  assertNull(getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE));
}
origin: spring-projects/spring-framework

@Test
public void withErrorsAndDynamicAttributes() throws Exception {
  String dynamicAttribute1 = "attr1";
  String dynamicAttribute2 = "attr2";
  this.tag.setDynamicAttribute(null, dynamicAttribute1, dynamicAttribute1);
  this.tag.setDynamicAttribute(null, dynamicAttribute2, dynamicAttribute2);
  // construct an errors instance of the tag
  TestBean target = new TestBean();
  target.setName("Rob Harrop");
  Errors errors = new BeanPropertyBindingResult(target, COMMAND_NAME);
  errors.rejectValue("name", "some.code", "Default Message");
  errors.rejectValue("name", "too.short", "Too Short");
  exposeBindingResult(errors);
  int result = this.tag.doStartTag();
  assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
  result = this.tag.doEndTag();
  assertEquals(Tag.EVAL_PAGE, result);
  String output = getOutput();
  assertElementTagOpened(output);
  assertElementTagClosed(output);
  assertContainsAttribute(output, "id", "name.errors");
  assertContainsAttribute(output, dynamicAttribute1, dynamicAttribute1);
  assertContainsAttribute(output, dynamicAttribute2, dynamicAttribute2);
  assertBlockTagContains(output, "<br/>");
  assertBlockTagContains(output, "Default Message");
  assertBlockTagContains(output, "Too Short");
}
origin: spring-projects/spring-framework

@Test
public void asBodyTagWithExistingMessagesAttribute() throws Exception {
  String existingAttribute = "something";
  getPageContext().setAttribute(ErrorsTag.MESSAGES_ATTRIBUTE, existingAttribute);
  Errors errors = new BeanPropertyBindingResult(new TestBean(), "COMMAND_NAME");
  errors.rejectValue("name", "some.code", "Default Message");
  errors.rejectValue("name", "too.short", "Too Short");
  exposeBindingResult(errors);
  int result = this.tag.doStartTag();
  assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
  assertNotNull(getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE));
  assertTrue(getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE) instanceof List);
  String bodyContent = "Foo";
  this.tag.setBodyContent(new MockBodyContent(bodyContent, getWriter()));
  this.tag.doEndTag();
  this.tag.doFinally();
  assertEquals(bodyContent, getOutput());
  assertEquals(existingAttribute, getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE));
}
origin: spring-projects/spring-framework

/**
 * https://jira.spring.io/browse/SPR-2788
 */
@Test
public void asBodyTagWithErrorsAndExistingMessagesAttributeInNonPageScopeAreNotClobbered() throws Exception {
  String existingAttribute = "something";
  getPageContext().setAttribute(ErrorsTag.MESSAGES_ATTRIBUTE, existingAttribute, PageContext.APPLICATION_SCOPE);
  Errors errors = new BeanPropertyBindingResult(new TestBean(), "COMMAND_NAME");
  errors.rejectValue("name", "some.code", "Default Message");
  errors.rejectValue("name", "too.short", "Too Short");
  exposeBindingResult(errors);
  int result = this.tag.doStartTag();
  assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
  assertNotNull(getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE));
  assertTrue(getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE) instanceof List);
  String bodyContent = "Foo";
  this.tag.setBodyContent(new MockBodyContent(bodyContent, getWriter()));
  this.tag.doEndTag();
  this.tag.doFinally();
  assertEquals(bodyContent, getOutput());
  assertEquals(existingAttribute,
      getPageContext().getAttribute(ErrorsTag.MESSAGES_ATTRIBUTE, PageContext.APPLICATION_SCOPE));
}
origin: org.metawidget.modules/metawidget-all

errorsTag.doEndTag();
origin: stackoverflow.com

errorsTag.doInitBody();
errorsTag.doAfterBody();
errorsTag.doEndTag();
out = pageContext.popBody();
errorsTag.release();
org.springframework.web.servlet.tags.formErrorsTagdoEndTag

Popular methods of ErrorsTag

  • getElement
    Get the HTML element must be used to render the error messages.
  • doStartTag
  • evaluate
  • getDelimiter
    Return the delimiter to be used between error messages.
  • getPropertyPath
  • setPageContext
  • setPath
  • writeDefaultAttributes
  • <init>
  • getBindStatus
  • getDisplayString
  • setBodyContent
  • getDisplayString,
  • setBodyContent,
  • setParent,
  • doAfterBody,
  • doFinally,
  • doInitBody,
  • release,
  • setCssClass,
  • setCssStyle

Popular in Java

  • Making http post requests using okhttp
  • compareTo (BigDecimal)
  • getSharedPreferences (Context)
  • putExtra (Intent)
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now