[SPR-5927] fixed FormTag attribute clearing
This commit is contained in:
parent
b18a1dc5b3
commit
afd6fe9048
|
|
@ -423,6 +423,15 @@ public class FormTag extends AbstractHtmlElementTag {
|
|||
@Override
|
||||
public int doEndTag() throws JspException {
|
||||
this.tagWriter.endTag();
|
||||
return EVAL_PAGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the stored {@link TagWriter}.
|
||||
*/
|
||||
@Override
|
||||
public void doFinally() {
|
||||
super.doFinally();
|
||||
this.pageContext.removeAttribute(MODEL_ATTRIBUTE_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
this.pageContext.removeAttribute(COMMAND_NAME_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
if (this.previousNestedPath != null) {
|
||||
|
|
@ -433,15 +442,6 @@ public class FormTag extends AbstractHtmlElementTag {
|
|||
// Remove exposed nestedPath value.
|
||||
this.pageContext.removeAttribute(NESTED_PATH_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
}
|
||||
return EVAL_PAGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the stored {@link TagWriter}.
|
||||
*/
|
||||
@Override
|
||||
public void doFinally() {
|
||||
super.doFinally();
|
||||
this.tagWriter = null;
|
||||
this.previousNestedPath = null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,6 +253,16 @@ public class FormTagTests extends AbstractHtmlElementTagTests {
|
|||
assertContainsAttribute(inputOutput, "type", "hidden");
|
||||
}
|
||||
|
||||
public void testClearAttributesOnFinally() throws Exception {
|
||||
this.tag.setModelAttribute("model");
|
||||
getPageContext().setAttribute("model", "foo bar");
|
||||
assertNull(getPageContext().getAttribute(FormTag.MODEL_ATTRIBUTE_VARIABLE_NAME, PageContext.REQUEST_SCOPE));
|
||||
this.tag.doStartTag();
|
||||
assertNotNull(getPageContext().getAttribute(FormTag.MODEL_ATTRIBUTE_VARIABLE_NAME, PageContext.REQUEST_SCOPE));
|
||||
this.tag.doFinally();
|
||||
assertNull(getPageContext().getAttribute(FormTag.MODEL_ATTRIBUTE_VARIABLE_NAME, PageContext.REQUEST_SCOPE));
|
||||
}
|
||||
|
||||
private String getFormTag(String output) {
|
||||
int inputStart = output.indexOf("<", 1);
|
||||
int inputEnd = output.lastIndexOf(">", output.length() - 2);
|
||||
|
|
|
|||
Loading…
Reference in New Issue