This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/struts.git
The following commit(s) were added to refs/heads/main by this push:
new b8da6b5d2 WW-5780 fix(html5): close the checkbox input in the html5
checkboxlist template (#2025)
b8da6b5d2 is described below
commit b8da6b5d2e6103b2375d71c710e66a876491dadf
Author: Lukasz Lenart <[email protected]>
AuthorDate: Fri Oct 16 09:10:52 2026 +0200
WW-5780 fix(html5): close the checkbox input in the html5 checkboxlist
template (#2025)
Without the closing /> the browser parsed the following <label as attribute
names of the input, so no label element was created for any item.
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../main/resources/template/html5/checkboxlist.ftl | 1 +
.../struts2/views/jsp/ui/CheckboxListTest.java | 24 ++++++++++++++++++++++
.../struts2/views/jsp/ui/CheckboxList-2-html5.txt | 7 +++++++
3 files changed, 32 insertions(+)
diff --git a/core/src/main/resources/template/html5/checkboxlist.ftl
b/core/src/main/resources/template/html5/checkboxlist.ftl
index 7a1d81f0d..0a2550aed 100644
--- a/core/src/main/resources/template/html5/checkboxlist.ftl
+++ b/core/src/main/resources/template/html5/checkboxlist.ftl
@@ -98,6 +98,7 @@
<#include
"/${attributes.templateDir}/${attributes.expandTheme}/common-attributes.ftl"
/><#rt/>
<#global evaluate_dynamic_attributes = true/><#t/>
<#include
"/${attributes.templateDir}/${attributes.expandTheme}/dynamic-attributes.ftl"
/><#rt/>
+/><#rt/>
<label<#rt/>
<#if attributes.id?has_content>
for="${attributes.id}-${itemCount}"<#rt/>
diff --git
a/core/src/test/java/org/apache/struts2/views/jsp/ui/CheckboxListTest.java
b/core/src/test/java/org/apache/struts2/views/jsp/ui/CheckboxListTest.java
index 050dbdbb1..72ce56933 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/ui/CheckboxListTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/CheckboxListTest.java
@@ -23,6 +23,7 @@ import org.apache.struts2.views.jsp.AbstractUITagTest;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
@@ -72,6 +73,29 @@ public class CheckboxListTest extends AbstractUITagTest {
verifyGenericProperties(tag, "html5", new
String[]{"tabindex","cssClass","cssStyle","id"});
}
+ public void testMultipleHtml5() throws Exception {
+ TestAction testAction = (TestAction) action;
+ testAction.setCollection(List.of("hello", "foo"));
+ testAction.setList(new String[][]{
+ {"hello", "world"},
+ {"foo", "bar"},
+ {"cat", "dog"}
+ });
+
+ CheckboxListTag tag = new CheckboxListTag();
+ tag.setPageContext(pageContext);
+ tag.setTheme("html5");
+ tag.setName("collection");
+ tag.setList("list");
+ tag.setListKey("top[0]");
+ tag.setListValue("top[1]");
+
+ tag.doStartTag();
+ tag.doEndTag();
+
+ verify(CheckboxListTag.class.getResource("CheckboxList-2-html5.txt"));
+ }
+
private void prepareTagGeneric(CheckboxListTag tag) {
TestAction testAction = (TestAction) action;
Collection<String> collection = new ArrayList<String>(2);
diff --git
a/core/src/test/resources/org/apache/struts2/views/jsp/ui/CheckboxList-2-html5.txt
b/core/src/test/resources/org/apache/struts2/views/jsp/ui/CheckboxList-2-html5.txt
new file mode 100644
index 000000000..43cac1c10
--- /dev/null
+++
b/core/src/test/resources/org/apache/struts2/views/jsp/ui/CheckboxList-2-html5.txt
@@ -0,0 +1,7 @@
+<input type="checkbox" name="collection" value="hello" id="collection-1"
checked="checked"/>
+<label for="collection-1" class="checkboxLabel">world</label>
+<input type="checkbox" name="collection" value="foo" id="collection-2"
checked="checked"/>
+<label for="collection-2" class="checkboxLabel">bar</label>
+<input type="checkbox" name="collection" value="cat" id="collection-3"/>
+<label for="collection-3" class="checkboxLabel">dog</label>
+<input type="hidden" id="__multiselect_collection"
name="__multiselect_collection" value=""/>