struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [struts] branch master updated: Fixes translating id in Form tag
Date Wed, 02 Dec 2020 19:16:30 GMT
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/struts.git


The following commit(s) were added to refs/heads/master by this push:
     new 87d42d6  Fixes translating id in Form tag
87d42d6 is described below

commit 87d42d60c98b6651141ca6aa20ddc42919fe1ecc
Author: Lukasz Lenart <lukaszlenart@apache.org>
AuthorDate: Wed Nov 25 17:12:57 2020 +0100

    Fixes translating id in Form tag
---
 .../main/java/org/apache/struts2/components/Form.java |  2 +-
 .../org/apache/struts2/views/jsp/ui/FormTagTest.java  | 19 +++++++++++++++++++
 .../org/apache/struts2/views/jsp/ui/Formtag-29.txt    |  3 +++
 3 files changed, 23 insertions(+), 1 deletion(-)

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 @@ 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 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 @@ 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 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>


Mime
View raw message