From Documentation

Jump to: navigation, search

Before using a theme, it must be registered so that the system knows about its existence and where to retrieve its resources (from a jar file or from a folder). Themes provides several static methods for registering your themes.

Available in ZK all editions

Registration, in its simplest form, is to tell the web application about the name of the theme. It will be assumed that the theme is for desktop only, and its resources should be retrieved from a jar file. For example,

Available in ZK 6.5.2+ all editions

Starting from ZK 6.5.2, theme resources could also be retrieved from a folder. To indicate that a theme is folder-based, please use StandardTheme.ThemeOrigin to specify the origin of the theme resources, like below.

Themes.register("custom", ThemeOrigin.FOLDER);
Available in ZK EE 6.5.2+

In ZK EE 6.5.0+, components would appear differently when viewed on tablet devices. A custom theme could be applicable to desktop only, tablet only, or both. To signify that a theme also serves tablet devices, please attach a "tablet:" prefix in front of the theme name when registering. For example,


Creating Custom Theme Registration Service

Available in ZK 6.5.2+ all editions

ThemeRegistry defines the interface to create a repository of themes available to the web application. DesktopThemeRegistry (for ZK CE/PE) and ResponsiveThemeRegistry (for ZK EE) are the standard implementations that actually stores the registered themes.

Standard theme registries would accept all theme registrations. Duplicate registration would update theme information. Registered themes are available to all users. (For ZK EE, desktop clients would only have desktop themes available, and tablet clients would only have tablet themes available.) If you would like to modify any of these behaviors, please provide a custom ThemeRegistry.

For example, a custom ThemeRegistry could be created by implementing ThemeRegistry interface directly, or extending one of the standard implementations, depending on the ZK edition you are using.

package foo;

public class CustomThemeRegistry implements ThemeRegistry {

And then, configure the custom ThemeRegistry in WEB-INF/zk.xml.


To access the current theme registry, please refer to ThemeFns.getThemeRegistry() and ThemeFns.setThemeRegistry(ThemeRegistry).