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

   Part of [WW-5702](https://issues.apache.org/jira/browse/WW-5702) — items 1, 
3, 4, 7 and 13 (the Form/UIBean scope gaps). Provider hygiene (2, 5, 6, 8–11) 
and the six html5 templates (12) follow in separate PRs.
   
   ## What changed
   
   - **Item 1 — derivation is gated on the theme.** 
`UIBean.addConstraintAttributes` now bails unless the resolved theme, or one of 
its `theme.properties` ancestors, is `html5` — the only theme whose templates 
render `attributes.constraints`. `xhtml`/`simple`/`css_xhtml` forms no longer 
resolve validators and call `getMessage()` per field to build a map nothing 
renders. The walk reuses `Template.getPossibleTemplates` over the cached theme 
properties, so a custom theme with `parent = html5` keeps deriving; the gate is 
by ancestry name, not capability, and the Javadoc says so. 
`ConstraintAttributesTest` now sets the theme explicitly (it was asserting 
derivation under xhtml).
   - **Item 4 — visitor-validated fields get their concrete constraint.** 
`Form.getFieldValidators` unwraps `FieldVisitorValidatorWrapper`, so 
`user.name` behind a `visitor` on `user` renders `required` + 
`data-msg-requiredstring` instead of `data-msg-field-visitor` and nothing else. 
The wrapper stays on the deprecated `getValidators(String)` path, where the 
prefixed name is what the JS validator needs.
   - **Item 13 — visitor validators are resolved once per form**, keyed by the 
visited class, instead of once per field.
   - **Item 7 — `Checkbox` and `Hidden` report their real `HtmlControlType`.** 
Inert with the default provider (neither type supports a constraint and 
`addRequiredField` admits only `RADIO`/`FILE`), but a replacement provider can 
now tell them from an unknown control.
   
   ## Item 3 is a false finding
   
   `Component.findValue(null, String.class)` returns `null` — 
`ComponentUtils.containsExpression(null)` is false, so the `OgnlTextParser` 
coercion to `""` is never reached — and `DefaultActionMapper.parseActionName` 
returns `null` for a null name. The `attributes.actionName` fallback is 
therefore reachable for a form without an `action` attribute. The new 
`testFindsAliasScopedValidatorsForAFormWithoutAnActionAttribute` proves 
alias-scoped validators are found with no production change; it stays as the 
coverage the ticket asked for.
   
   ## Follow-up
   
   Review surfaced that visitor-nested `data-msg-*` text is resolved against 
the action's bundles only, while `VisitorFieldValidator` validates with a 
composite provider over the visited object too — a `<message key=.../>` living 
in the visited class's own `.properties` renders as the raw key. Pre-existing 
(the wrapper delegated `getMessage(action)` the same way) but now visible under 
the real validator type. Filed as 
[WW-5740](https://issues.apache.org/jira/browse/WW-5740); fixing it needs the 
provider to receive the visited object.
   
   ## Tests
   
   `mvn test -DskipAssembly -pl core`: 3342 tests, 0 failures. Every production 
change went red first; the end-to-end visitor test was re-run without the 
`Form` change to confirm it fails.
   
   🤖 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to