diff --git a/source/core-developers/package-configuration.md b/source/core-developers/package-configuration.md index 62072b2bc2..e5782bd0ee 100644 --- a/source/core-developers/package-configuration.md +++ b/source/core-developers/package-configuration.md @@ -101,7 +101,7 @@ The element requires the [struts-7.5.dtd](../dtds/struts-7.5.dtd) and must come "https://struts.apache.org/dtds/struts-7.5.dtd"> - + ... @@ -117,9 +117,13 @@ framework components once, at startup, so a package value only takes effect wher it per request. Such a component declares the constants it reads as _scopable_, and only those can appear in ``. -{:.alert .alert-warning} -Struts core does not declare any constant as scopable yet. A `` only works with a constant -declared scopable by a plugin or by your own application code. +Since Struts 7.5.0 these core constants are scopable: + +- `struts.ui.theme`, the default theme of UI tags, see [Selecting Themes](../tag-developers/selecting-themes) +- `struts.ui.templateDir`, the default template directory of UI tags, see + [Selecting Template Directory](../tag-developers/selecting-template-directory) + +Plugins and your own application code can declare more, see [Making a constant scopable](#making-a-constant-scopable). The configuration is validated at startup, and loading fails when: @@ -133,7 +137,7 @@ value is static: ```xml - + ... ``` diff --git a/source/getting-started/themes.md b/source/getting-started/themes.md index 6304309ecc..c91ba6c449 100644 --- a/source/getting-started/themes.md +++ b/source/getting-started/themes.md @@ -73,7 +73,8 @@ Struts should use: 4. The request-scoped attribute named `theme` 5. The session-scoped attribute named `theme` 6. The application-scoped attribute named `theme` -7. The `struts.ui.theme` constant in `struts.xml` (defaults to `xhtml`) +7. The `struts.ui.theme` scoped constant of the action's package (since 7.5.0) +8. The `struts.ui.theme` constant in `struts.xml` (defaults to `xhtml`) Consult [Selecting Themes](../tag-developers/selecting-themes) for how to set the theme using the above approaches. diff --git a/source/tag-developers/selecting-template-directory.md b/source/tag-developers/selecting-template-directory.md index 2cde004871..9439c7031b 100644 --- a/source/tag-developers/selecting-template-directory.md +++ b/source/tag-developers/selecting-template-directory.md @@ -12,8 +12,12 @@ Template directory can be selected using several different rules, in this order: 3. The request-scoped attribute named `templateDir` 4. The session-scoped attribute named `templateDir` 5. The application-scoped attribute named `templateDir` -6. The `struts.ui.templateDir` property in `struts.xml` (defaults to _template_) +6. The `struts.ui.templateDir` [scoped constant](../core-developers/package-configuration#scoped-constants) of the + action's package or one of its parents (since 7.5.0) +7. The `struts.ui.templateDir` property in `struts.xml` (defaults to _template_) ## Tips -- To change the template directory for the entire application, modify the `struts.xml` +- To change the template directory for the entire application, modify the `struts.xml` +- To change the template directory for all actions of a package, declare + `` in that package (since 7.5.0) diff --git a/source/tag-developers/selecting-themes.md b/source/tag-developers/selecting-themes.md index 8149857346..929e57f1a5 100644 --- a/source/tag-developers/selecting-themes.md +++ b/source/tag-developers/selecting-themes.md @@ -13,7 +13,9 @@ Themes can be selected using several different rules, in this order: 4. The request-scoped attribute named `theme` 5. The session-scoped attribute named `theme` 6. The application-scoped attribute named `theme` -7. The `struts.ui.theme` property in `struts.xml` (defaults to _xhtml_) +7. The `struts.ui.theme` [scoped constant](../core-developers/package-configuration#scoped-constants) of the action's + package or one of its parents (since 7.5.0) +8. The `struts.ui.theme` property in `struts.xml` (defaults to _xhtml_) See [Can I change theme on a per-page basis]() page for using scoped `theme` attribute. @@ -22,4 +24,6 @@ See [Can I change theme on a per-page basis]() page for using scoped `theme` att - To override an entire form's theme, change the "theme" attribute of the form. (Convenient for using the [ajax theme](ajax-theme) for specific forms, for example.) - To support user-selected themes, set the theme in the user's session. +- To change the theme for all actions of a package, declare + `` in that package (since 7.5.0). - To change the theme for the entire application, modify the `struts.xml`. diff --git a/source/tag-developers/template-loading.md b/source/tag-developers/template-loading.md index 4a106d037f..c74b621059 100644 --- a/source/tag-developers/template-loading.md +++ b/source/tag-developers/template-loading.md @@ -20,7 +20,8 @@ overridden, an edited copy can be placed in the application, so that is found fi ## Template and Themes Templates are loaded based the template directory and theme name (see [Selecting Themes](selecting-themes)). -The template directory is defined by the `struts.ui.templateDir` property in `struts.xml` (defaults to `template`). +The template directory is defined by the `struts.ui.templateDir` property in `struts.xml` (defaults to `template`), +and can be overridden per package or per tag (see [Selecting Template Directory](selecting-template-directory)). If a tag is using the `xhtml` theme, the following two locations will be searched (in this order): |In the application|`/template/xhtml/template.ftl`|