diff --git a/core/src/main/java/org/apache/struts2/components/Form.java b/core/src/main/java/org/apache/struts2/components/Form.java index 9758cf325..44bdd0999 100644 --- a/core/src/main/java/org/apache/struts2/components/Form.java +++ b/core/src/main/java/org/apache/struts2/components/Form.java @@ -221,7 +221,7 @@ public class Form extends ClosingUIBean { @Override protected void populateComponentHtmlId(Form form) { if (id != null) { - addParameter("id", escape(id)); + super.populateComponentHtmlId(null); } // if no id given, it will be tried to generate it from the action attribute diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java index 1ccbb891d..79abd4c2c 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java @@ -189,6 +189,25 @@ public class FormTagTest extends AbstractUITagTest { verify(FormTag.class.getResource("Formtag-1.txt")); } + public void testFormId() throws Exception { + + request.setupGetServletPath("/testAction"); + + TestAction testAction = (TestAction) action; + testAction.setFoo("bar"); + + FormTag tag = new FormTag(); + tag.setPageContext(pageContext); + tag.setMethod("post"); + tag.setAction("myAction"); + tag.setId("myid-%{foo}"); + + tag.doStartTag(); + tag.doEndTag(); + + verify(FormTag.class.getResource("Formtag-29.txt")); + } + public void testFormNoNameOrId() throws Exception { request.setupGetServletPath("/testAction"); diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-29.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-29.txt new file mode 100644 index 000000000..1337f579e --- /dev/null +++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-29.txt @@ -0,0 +1,3 @@ +
+
+