zkzulzk-grid

How to Dynamically apply our own custom themes in zk 8.5


I have made my own custom theme.

As i set this theme in zk.xml

<library-property>
     <name>org.zkoss.theme.preferred</name> 
    <value>MYTheme</value>
 </library-property>

the theme is being applied ,but as i will be creating My own multiple custom themes how do i choose it programitacally?


Solution

  • The available methods and a way to customize the theme resolution are described in our documentation on Switching Themes.

    You can change the default theme for all users at runtime by setting the library property (after reloading the page the theme is applied):

    Library.setProperty("org.zkoss.theme.preferred", "custom");
    Executions.sendRedirect("");
    

    To switch the theme for an individual user the following method sets a cookie (by default):

    Themes.setTheme(Executions.getCurrent(), "custom");
    Executions.sendRedirect("");
    

    Robert