Search code examples
javacsszk

Include css file in richlet with zk


I'm working on creating a view only with java in a ZK Richlet and I'm trying to include a css file in the Richlet but I didn't find a way to do that.


Solution

  • One option is to utilize the desktop-config element of your zk.xml. Especially the theme-uri and theme-provider-class elements are used to apply additional style classes.

    <desktop-config>
        <theme-uri>/to/your/css.css</theme-uri>
    </desktop-config>
    

    Another option - although not recommended by the class' API - is to use the addBeforeHeadTags method of PageCtrl:

    ((PageCtrl)page).addBeforeHeadTags("<link rel=\"stylesheet\" type=\"text/css\" href=\"/to/your/css.css\" />");