Java Code Examples for org.springframework.web.servlet.tags.form.FormTag#setPageContext()

The following examples show how to use org.springframework.web.servlet.tags.form.FormTag#setPageContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BindTagTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * 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();
}
 
Example 2
Source File: BindTagTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * 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();
}
 
Example 3
Source File: BindTagTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * 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.setCommandName(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();
}