Fixes translating id in Form tag
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 9758cf3..44bdd09 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 @@
@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 1ccbb89..79abd4c 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 @@
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 0000000..1337f57
--- /dev/null
+++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-29.txt
@@ -0,0 +1,3 @@
+<form id="myid-bar" name="myid-bar" action="myAction" method="post">
+ <table class="wwFormTable"></table>
+</form>