use of org.springframework.web.servlet.tags.form.TagWriter in project spring-framework by spring-projects.
the class BindTagTests method nestingInFormTag.
/**
* SPR-4022
*/
@SuppressWarnings("serial")
@Test
public void nestingInFormTag() throws JspException {
PageContext pc = createPageContext();
TestBean tb = new TestBean();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
ServletRequestDataBinder binder = new ServletRequestDataBinder(tb, "tb");
CustomDateEditor l = new CustomDateEditor(df, true);
binder.registerCustomEditor(Date.class, l);
pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", binder.getBindingResult());
FormTag formTag = new FormTag() {
@Override
protected TagWriter createTagWriter() {
return new TagWriter(new StringWriter());
}
};
String action = "/form.html";
String commandName = "tb";
String name = "formName";
String enctype = "my/enctype";
String method = "POST";
String onsubmit = "onsubmit";
String onreset = "onreset";
String cssClass = "myClass";
String cssStyle = "myStyle";
String acceptCharset = "iso-8859-1";
formTag.setName(name);
formTag.setCssClass(cssClass);
formTag.setCssStyle(cssStyle);
formTag.setAction(action);
formTag.setModelAttribute(commandName);
formTag.setEnctype(enctype);
formTag.setMethod(method);
formTag.setOnsubmit(onsubmit);
formTag.setOnreset(onreset);
formTag.setAcceptCharset(acceptCharset);
formTag.setPageContext(pc);
formTag.doStartTag();
BindTag bindTag1 = new BindTag();
bindTag1.setPageContext(pc);
bindTag1.setPath("date");
bindTag1.doStartTag();
bindTag1.doEndTag();
BindTag bindTag2 = new BindTag();
bindTag2.setPageContext(pc);
bindTag2.setPath("tb.date");
bindTag2.doStartTag();
bindTag2.doEndTag();
BindTag bindTag3 = new BindTag();
bindTag3.setPageContext(pc);
bindTag3.setPath("tb");
bindTag3.doStartTag();
bindTag3.doEndTag();
formTag.doEndTag();
}
Aggregations