Search in sources :

Example 46 with BindStatus

use of org.springframework.web.servlet.support.BindStatus in project spring-framework by spring-projects.

the class BindTagTests method bindTagWithToStringAndHtmlEscaping.

@Test
public void bindTagWithToStringAndHtmlEscaping() throws JspException {
    PageContext pc = createPageContext();
    BindTag tag = new BindTag();
    tag.setPageContext(pc);
    tag.setPath("tb.doctor");
    tag.setHtmlEscape(true);
    TestBean tb = new TestBean("somebody", 99);
    NestedTestBean ntb = new NestedTestBean("juergen&eva");
    tb.setDoctor(ntb);
    pc.getRequest().setAttribute("tb", tb);
    tag.doStartTag();
    BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
    assertEquals("doctor", status.getExpression());
    assertTrue(status.getValue() instanceof NestedTestBean);
    assertTrue(status.getDisplayValue().indexOf("juergen&eva") != -1);
}
Also used : IndexedTestBean(org.springframework.tests.sample.beans.IndexedTestBean) TestBean(org.springframework.tests.sample.beans.TestBean) NestedTestBean(org.springframework.tests.sample.beans.NestedTestBean) NestedTestBean(org.springframework.tests.sample.beans.NestedTestBean) PageContext(javax.servlet.jsp.PageContext) BindStatus(org.springframework.web.servlet.support.BindStatus) Test(org.junit.Test)

Example 47 with BindStatus

use of org.springframework.web.servlet.support.BindStatus in project spring-framework by spring-projects.

the class BindTagTests method bindTagWithFieldButWithoutErrorsInstance.

@Test
public void bindTagWithFieldButWithoutErrorsInstance() throws JspException {
    PageContext pc = createPageContext();
    BindTag tag = new BindTag();
    tag.setPageContext(pc);
    tag.setPath("tb.name");
    pc.getRequest().setAttribute("tb", new TestBean("juergen&eva", 99));
    tag.doStartTag();
    BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
    assertEquals("name", status.getExpression());
    assertEquals("juergen&eva", status.getValue());
}
Also used : IndexedTestBean(org.springframework.tests.sample.beans.IndexedTestBean) TestBean(org.springframework.tests.sample.beans.TestBean) NestedTestBean(org.springframework.tests.sample.beans.NestedTestBean) PageContext(javax.servlet.jsp.PageContext) BindStatus(org.springframework.web.servlet.support.BindStatus) Test(org.junit.Test)

Aggregations

BindStatus (org.springframework.web.servlet.support.BindStatus)47 Test (org.junit.Test)44 TestBean (org.springframework.tests.sample.beans.TestBean)22 PageContext (javax.servlet.jsp.PageContext)19 IndexedTestBean (org.springframework.tests.sample.beans.IndexedTestBean)19 NestedTestBean (org.springframework.tests.sample.beans.NestedTestBean)18 Errors (org.springframework.validation.Errors)14 ServletRequestDataBinder (org.springframework.web.bind.ServletRequestDataBinder)14 PropertyEditor (java.beans.PropertyEditor)4 StringReader (java.io.StringReader)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Document (org.dom4j.Document)4 Element (org.dom4j.Element)4 SAXReader (org.dom4j.io.SAXReader)4 StringArrayPropertyEditor (org.springframework.beans.propertyeditors.StringArrayPropertyEditor)4 MockBodyContent (org.springframework.mock.web.test.MockBodyContent)3 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)2 BindTag (org.springframework.web.servlet.tags.BindTag)2 SimpleHash (freemarker.template.SimpleHash)1