You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@struts.apache.org by "lukaszlenart (via GitHub)" <gi...@apache.org> on 2026/10/16 05:38:09 UTC

[PR] WW-5781 fix(tags): render a single class and style on checkboxlist and radio inputs [struts]

lukaszlenart opened a new pull request, #2026:
URL: https://github.com/apache/struts/pull/2026

   Fixes [WW-5781](https://issues.apache.org/jira/browse/WW-5781)
   
   ## Problem
   
   Both tags wrote `class`/`style` on each input themselves and then included `css.ftl`, which wrote them a second time. `<s:checkboxlist>` did this whenever `cssClass` or `cssStyle` was set; `<s:radio>` did it whenever `listCssClass` or `listCssStyle` was set:
   
   ```html
   <input type="checkbox" ... class="myClass" style="mystyle" class="myClass errclass" style="errstyle"/>
   ```
   
   Browsers keep the first copy of a duplicate attribute. So the error class and style that `css.ftl` adds came second and were dropped, which meant `cssErrorClass` and `cssErrorStyle` never took effect on these inputs.
   
   ## Fix
   
   A new shared include, `template/simple/list-item-css.ftl`, writes exactly one `class` and one `style` per item. The html5 theme picks it up through its parent theme, `simple`.
   
   - **class:** `listCssClass` if it is non-empty, otherwise `cssClass`. When the field has errors, `cssErrorClass` is appended.
   - **style:** `cssErrorStyle` when the field has errors and it is set. Otherwise `listCssStyle` if non-empty, otherwise `cssStyle`, which is dropped when an error class applies (the existing `css.ftl` rule).
   
   The item value replacing the tag value is what browsers already render today, so ordinary pages look the same. `css.ftl` itself is unchanged, so the other tags and any custom themes that override it are unaffected. The radio `<label>` still uses `css.ftl`, as before.
   
   **What changes for users:**
   - `cssErrorClass` and `cssErrorStyle` now work on checkbox and radio items.
   - Checkboxlist with a `listCssClass` that evaluates to an empty string used to render `class=""` first, which hid `cssClass`. It now falls back to `cssClass`, as radio already did.
   - Checkboxlist with field errors, `cssErrorClass` and `cssStyle` (but no `cssErrorStyle`) no longer renders `cssStyle`. This matches `css.ftl` and every other tag.
   
   ## Tests
   
   - New expected-output fixtures for checkboxlist (`cssClass` only, item class replacing `cssClass`, field errors) and for radio (item class in simple and html5, field errors). An html5 checkboxlist test counts the `class`/`style` attributes rather than comparing a whole fixture, because the html5 checkboxlist markup is being fixed separately in #2025. All 7 new tests failed before the fix, on the duplicate attributes.
   - `FreemarkerResultMockedTest` loads templates only from a mocked servlet context and allows each template by name, so it needed the new include added to that list.
   - `mvn test -pl core`: 3479 tests, 0 failures.
   
   Merges with #2025 (WW-5780) without conflicts.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] WW-5781 fix(tags): render a single class and style on checkboxlist and radio inputs [struts]

Posted by "lukaszlenart (via GitHub)" <gi...@apache.org>.
lukaszlenart merged PR #2026:
URL: https://github.com/apache/struts/pull/2026


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] WW-5781 fix(tags): render a single class and style on checkboxlist and radio inputs [struts]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #2026:
URL: https://github.com/apache/struts/pull/2026#issuecomment-6209221743

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=2026) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=2026&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=2026&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_struts&pullRequest=2026&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=2026&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=2026&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=2026)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org