Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions source/core-developers/package-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<struts>
<package name="admin" extends="struts-default" namespace="/admin">
<scoped-constant name="some.scopable.constant" value="x"/>
<scoped-constant name="struts.ui.theme" value="css_xhtml"/>
...
</package>
</struts>
Expand All @@ -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 `<scoped-constant>`.

{:.alert .alert-warning}
Struts core does not declare any constant as scopable yet. A `<scoped-constant>` 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:

Expand All @@ -133,7 +137,7 @@ value is static:

```xml
<package name="admin" extends="struts-default" namespace="/admin">
<scoped-constant name="some.scopable.constant" value="${env.ADMIN_VALUE:x}"/>
<scoped-constant name="struts.ui.theme" value="${env.ADMIN_THEME:css_xhtml}"/>
...
</package>
```
Expand Down
3 changes: 2 additions & 1 deletion source/getting-started/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
8 changes: 6 additions & 2 deletions source/tag-developers/selecting-template-directory.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
`<scoped-constant name="struts.ui.templateDir" value="admin-template"/>` in that package (since 7.5.0)
6 changes: 5 additions & 1 deletion source/tag-developers/selecting-themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
`<scoped-constant name="struts.ui.theme" value="css_xhtml"/>` in that package (since 7.5.0).
- To change the theme for the entire application, modify the `struts.xml`.
3 changes: 2 additions & 1 deletion source/tag-developers/template-loading.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`|
Expand Down