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());
}
use of org.springframework.web.servlet.support.BindStatus in project spring-framework by spring-projects.
the class InputTagTests method simpleBindTagWithinForm.
@Test
public void simpleBindTagWithinForm() throws Exception {
BindTag bindTag = new BindTag();
bindTag.setPath("name");
bindTag.setPageContext(getPageContext());
bindTag.doStartTag();
BindStatus bindStatus = (BindStatus) getPageContext().findAttribute(BindTag.STATUS_VARIABLE_NAME);
assertEquals("Rob", bindStatus.getValue());
}
use of org.springframework.web.servlet.support.BindStatus in project spring-framework by spring-projects.
the class InputTagTests method withNestedBindTagWithinForm.
@Test
public void withNestedBindTagWithinForm() throws Exception {
NestedPathTag nestedPathTag = new NestedPathTag();
nestedPathTag.setPath("spouse.");
nestedPathTag.setPageContext(getPageContext());
nestedPathTag.doStartTag();
BindTag bindTag = new BindTag();
bindTag.setPath("name");
bindTag.setPageContext(getPageContext());
bindTag.doStartTag();
BindStatus bindStatus = (BindStatus) getPageContext().findAttribute(BindTag.STATUS_VARIABLE_NAME);
assertEquals("Sally", bindStatus.getValue());
}
use of org.springframework.web.servlet.support.BindStatus in project spring-framework by spring-projects.
the class OptionTagEnumTests method withJavaEnum.
@Test
@SuppressWarnings("rawtypes")
public void withJavaEnum() throws Exception {
GenericBean testBean = new GenericBean();
testBean.setCustomEnum(CustomEnum.VALUE_1);
getPageContext().getRequest().setAttribute("testBean", testBean);
String selectName = "testBean.customEnum";
getPageContext().setAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, new BindStatus(getRequestContext(), selectName, false));
this.tag.setValue("VALUE_1");
int result = this.tag.doStartTag();
assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
result = this.tag.doEndTag();
assertEquals(Tag.EVAL_PAGE, result);
String output = getWriter().toString();
assertOptionTagOpened(output);
assertOptionTagClosed(output);
assertContainsAttribute(output, "value", "VALUE_1");
assertContainsAttribute(output, "selected", "selected");
}
use of org.springframework.web.servlet.support.BindStatus in project spring-framework by spring-projects.
the class OptionTagTests method withPropertyEditor.
@Test
public void withPropertyEditor() throws Exception {
String selectName = "testBean.stringArray";
BindStatus bindStatus = new BindStatus(getRequestContext(), selectName, false) {
@Override
public PropertyEditor getEditor() {
return new StringArrayPropertyEditor();
}
};
getPageContext().setAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, bindStatus);
this.tag.setValue(ARRAY_SOURCE);
this.tag.setLabel("someArray");
int result = this.tag.doStartTag();
assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
result = this.tag.doEndTag();
assertEquals(Tag.EVAL_PAGE, result);
String output = getOutput();
assertOptionTagOpened(output);
assertOptionTagClosed(output);
assertContainsAttribute(output, "value", ARRAY_SOURCE);
assertContainsAttribute(output, "selected", "selected");
assertBlockTagContains(output, "someArray");
}
Aggregations