Repository navigation
WW-5768 Make struts.ui.theme and struts.ui.templateDir scopable per package - #2008
Merged
Merged
Conversation
…able per package A package can now override the default UI theme and template directory with <scoped-constant>, and child packages inherit it through extends. Only the last fallback in UIBean.getTheme()/getTemplateDir() changes: it asks the ScopedConstantProvider, which returns the package override or the global constant. The tag attribute, the enclosing form and the request/session/ application attributes keep their precedence. setDefaultUITheme/setDefaultTemplateDir and their fields are no longer read and are deprecated for removal. Components built without the container now need a ScopedConstantProvider, the same way they already need a CspNonceReader; the javatemplates tests set a stub. The empty-registry validation test now loads only the bootstrap beans, because StrutsDefaultConfigurationProvider registers the UI names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lukaszlenart
marked this pull request as ready for review
October 12, 2026 18:28
…elds Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Fixes WW-5768
Summary
This is the first adopter of package-scoped constants (WW-3476). A package can now override the default UI theme and template directory, and child packages inherit the override through
extends:StrutsUiScopableConstantsregisters the two names instruts-beans.xml, and inStrutsDefaultConfigurationProviderfor the test harness.UIBean.getTheme()/getTemplateDir()change only their last fallback step. It now callsScopedConstantProvider.getValue(...), which returns the package override or the global constant.Compatibility
setDefaultUITheme/setDefaultTemplateDirand thedefaultUITheme/defaultTemplateDirfields are no longer injected or read. They are marked@Deprecated(since = "7.5.0", forRemoval = true), and their removal is tracked in WW-5769 for 8.0.0.UIBeannow requires an injectedScopedConstantProvider, the same way it already requires aCspNonceReader. Components created by the container (JSP, FreeMarker and Velocity tags) are unaffected. Code that builds components by hand withoutcontainer.inject(...)must set one: the javatemplates tests now callsetScopedConstantProvider(name -> null)next to their existingsetCspNonceReader(...).getTheme()/getTemplateDir()call now performs a container lookup of the global constant instead of reading a field.<scoped-constant>with an empty value yields an empty theme. This matches the provider's existing contract (testEmptyOverrideIsReturnedAsIs).Tests
UIBeanScopedConstantsTestloadsstruts-default.xml(and thereforestruts-beans.xml). It covers:getTheme()made the form and request-attribute tests fail, so those tests do exercise the ordering.ScopedConstantsValidationTest:<scoped-constant name="struts.ui.theme">, which was rejected before this change, now loads.UIBeanTestinjects the provider or stubs it, instead of calling the deprecated setter.Results:
core: 3456 tests, 0 failures.Follow-up
core-developers/package-configuration.md(WW-3476 docs: document package-scoped constants struts-site#351), and mention the override on the themes and templates page.🤖 Generated with Claude Code