0

How to change theme ZK

asked 2017-10-25 19:25:06 +0800

softteam gravatar image softteam
45 3

updated 2017-10-27 14:29:21 +0800

Hello all,

I have problems with changing theme of a zul on IE, i have a Menu (.zul) with a theme (theme A) and one Menuitem (anotherwindow.zul) with another theme (theme B), I load the Menu with Theme A and when I open the other zul, Theme B doesn't load well on IE. I had the same issue on Chrome but I solved that with the liberary-property (<library-property> <name>org.zkoss.web.classWebResource.cache</name> <value>false</value> </library-property>) on the zk.xml but doesn't solve the problem on IE.

Seems like the problem is that IE doesn't clear the cache (chrome and mozzilla does it with the library property but not IE) any solution for that?

Thanks.

delete flag offensive retag edit

6 Answers

Sort by ยป oldest newest most voted
0

answered 2017-10-27 14:23:59 +0800

softteam gravatar image softteam
45 3

reply please

link publish delete flag offensive edit
0

answered 2017-10-30 18:23:24 +0800

MDuchemin gravatar image MDuchemin
1286 1 3
ZK Team

Hi Softteam,

The library property will prevent the web server from caching the result of wpd files compilation. As far as I know, it doesn't affect the client.

However, even if a new wpd file is generated, it will have no effect if the client still caches the old version. You can verify that this is the case by forcing a refresh in IE (ctrl+f5, or clear cache from menu)

You mention changing themes, usually that doesn't require manual refresh. Are you replacing a ZK theme value, or changing a css file?

Anyhow, be aware that the classWebResource library property will slow down your server compared to the default case, since all files located in the class web resource folder (including packaged scripts / styles used by the clients) will be regenerated for every request (every new page navigation, etc).

So, can you give some details on what you are doing? (replacing css file, swapping theme, etc?) and if the clear cache / ctrl+F5 confirms that you have a client side caching preventing you from getting the current version of your resources?

link publish delete flag offensive edit
0

answered 2017-10-30 20:25:09 +0800

softteam gravatar image softteam
45 3

Thanks for reply MDuchemin,

When I open the zul which I want to charge the other theme, I apply the theme using the Library.setProperty("org.zkoss.theme.preferred", theme); Themes.setTheme(Execution.getCurrent(), theme); and setting the Style to the page with the .css (new Style()) Before charging the .zul

Using the library-property (classWebResource.cache on false) don't need to refresh the page on Chrome and FF but on IE doesn't work and I need to refresh the page (don't need to force clear cache, just refresh page) If I change IE options to not save cache it works properly

link publish delete flag offensive edit
0

answered 2017-11-07 16:11:14 +0800

MDuchemin gravatar image MDuchemin
1286 1 3
ZK Team

Hey Softteam,

I got around to test the workflow described on my local machine, but I can't seem to reproduce your issue. Which ZK version are you using? And are you switching between 2 official themes, or your own custom themes?

link publish delete flag offensive edit
0

answered 2017-11-10 21:51:06 +0800

softteam gravatar image softteam
45 3

I'm using ZK 7 and the themes are: Sapphire and Atlantic with custom css, I charge the theme when I click to open the other Window

link publish delete flag offensive edit
0

answered 2017-11-24 15:17:16 +0800

MDuchemin gravatar image MDuchemin
1286 1 3
ZK Team

Hey Softteam,

Still can't get the same result in IE, Best I can see, IE is caching the Css file, since other browsers don't have this issue. If this is the case, you could customize the server output to force the client to refresh a file.

Looking at this resource, they recommend parameters to break cache https://css-tricks.com/strategies-for-cache-busting-css/ In Java, you could try to add a parameter to the files generated by WCSExtendlet https://github.com/zkoss/zk/blob/v8.5.0/zk/src/org/zkoss/zk/ui/http/WcsExtendlet.java Since the theme output by default is always .../zk.wcs, it might be skipped by IE even if the content changes. However, if you return .../zk.wcs?version=themename1, it will be reloaded when changing to ...zk.wcs?version=themename2 If you can change that param dynamically, then you should be able to force download on demand.

or if you are updating the WCSExtendlet anyway, you could just add cache control to the reply to force download every request with something like response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. response.setHeader("Pragma", "no-cache"); // HTTP 1.0. response.setDateHeader("Expires", 0); // Proxies. But you should be aware that this will waste some performance since you will be re-downloading theme for each page load

This said, if you can find why your IE is caching while other browsers are not, you might save time / implementation work on that side...

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2017-10-25 19:25:06 +0800

Seen: 27 times

Last updated: Nov 24