Setting themes | HCL Digital Experience
The Controller SPI enables the setting of themes on modifiable instances that implement
the ThemeSetter
interface, for example ContentPage
and ContentLabel
.
Procedure
- Obtain a modifiable instance of the resource for which you want to set a theme.
-
Obtain a
Theme
object from theThemeList
model. -
Check whether the resource implements the
ThemeSetter
interface.Use the operatorinstanceof
. If the resource does not implement theThemeSetter
interface, you cannot set the theme. -
Use the
setTheme()
method to set the theme.
Example
final Modifiable modifiable = cmController.getModifiableNode(page);
// obtain theme to set from com.ibm.portal.admin.ThemeList
final Theme theme = ...
// set theme
if (modifiable instanceof ThemeSetter) {
((ThemeSetter) modifiable).setTheme(theme);
}