...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<#include "/${parameters.templateDir}/xhtml${parameters.expandTheme}/controlheader.ftl" /> <#include "/${parameters.templateDir}/simple/xxx.ftl" /> <#include "/${parameters.templateDir}/xhtml${parameters.expandTheme}/controlfooter.ftl" /> |
Wrapping is a great way to augment the basic HTML elements provided by the simple theme.
...
One benefit of object-orientated programming is that it lets us "design by difference." We can extend an object and code only the behavior behaviour that changes. Themes provide a similar capability. The subdirectory that hosts a theme can contain a theme.properties
file. A parent
entry can be added to the property file to designate a theme to extend. The ajax theme extends the xhtml theme using this technique.
...
An extended theme does not need to implement every single template that the Struts Tags expect. It only needs to implement the templates that change. The other templates are loaded from the parent template.
Special parameters
UIBean provides few special parameters which can be used to build a new template (they are already used in xhtml
and css_xhtml
theme):
templateDir
- current value of templateDir parameter, see Selecting Template Directorytheme
- used theme, see Selecting ThemesthemeExpansionToken
- special token used to indicate to search for a template also in parent theme (when used with<#include />
directive)expandTheme
- tells internal template loader mechanism to try load template from current theme and then from parent theme (and parent theme, and so on)
Using expandTheme
parameter allows to override only some parts of the theme's templates, e.g. css.ftl. You can define a new theme (set theme.properties) and override just single file.
See also Creating a Theme in Struts 2 (Mark Menard)