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 638291af9 WW-3792 test(core): pin css_xhtml checkbox left-label 
wrappers to match other controls (#2041)
638291af9 is described below

commit 638291af96dd5822909394ee7ddf2e95e26c83e1
Author: Lukasz Lenart <[email protected]>
AuthorDate: Sat Oct 17 17:17:54 2026 +0200

    WW-3792 test(core): pin css_xhtml checkbox left-label wrappers to match 
other controls (#2041)
    
    Under css_xhtml every control wraps its label and control in <div> for
    labelPosition="top" and <span> otherwise. Pins that a checkbox with
    labelPosition="left" uses the same wrapper elements as a textfield.
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 .../apache/struts2/views/jsp/ui/CheckboxTest.java  | 37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git 
a/core/src/test/java/org/apache/struts2/views/jsp/ui/CheckboxTest.java 
b/core/src/test/java/org/apache/struts2/views/jsp/ui/CheckboxTest.java
index e7da044ca..ead481279 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/ui/CheckboxTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/CheckboxTest.java
@@ -25,6 +25,8 @@ import org.apache.struts2.TestAction;
 import org.apache.struts2.views.jsp.AbstractUITagTest;
 
 import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 public class CheckboxTest extends AbstractUITagTest {
 
@@ -233,6 +235,41 @@ public class CheckboxTest extends AbstractUITagTest {
             strutsBodyTagsAreReflectionEqual(tag, freshTag));
     }
 
+    public void testCssXhtmlLeftLabelPositionWrapsLikeTextfield() throws 
Exception {
+        TextFieldTag textfield = new TextFieldTag();
+        textfield.setPageContext(pageContext);
+        textfield.setId("textId");
+        textfield.setLabel("mylabel");
+        textfield.setName("foo");
+        textfield.setTheme("css_xhtml");
+        textfield.setLabelPosition("left");
+        textfield.doStartTag();
+        textfield.doEndTag();
+        String textfieldOutput = writer.toString();
+        writer.getBuffer().setLength(0);
+
+        CheckboxTag checkbox = new CheckboxTag();
+        checkbox.setPageContext(pageContext);
+        checkbox.setId("checkboxId");
+        checkbox.setLabel("mylabel");
+        checkbox.setName("foo");
+        checkbox.setFieldValue("baz");
+        checkbox.setTheme("css_xhtml");
+        checkbox.setLabelPosition("left");
+        checkbox.doStartTag();
+        checkbox.doEndTag();
+        String checkboxOutput = writer.toString();
+
+        assertEquals(wrapperElement(textfieldOutput, "wwlbl_textId"), 
wrapperElement(checkboxOutput, "wwlbl_checkboxId"));
+        assertEquals(wrapperElement(textfieldOutput, "wwctrl_textId"), 
wrapperElement(checkboxOutput, "wwctrl_checkboxId"));
+    }
+
+    private static String wrapperElement(String html, String id) {
+        Matcher matcher = Pattern.compile("<(\\w+)\\s+id=\"" + id + 
"\"").matcher(html);
+        assertTrue("No element with id " + id + " in: " + html, 
matcher.find());
+        return matcher.group(1);
+    }
+
     public void testCheckedWithError() throws Exception {
         TestAction testAction = (TestAction) action;
         testAction.setFoo("true");

Reply via email to