-
Bug
-
Resolution: Fixed
-
Normal
-
Freshly, 8.5.0
-
Security Level: Jimmy
-
None
-
None
Steps to Reproduce
try to change the current theme with websockets enabled
<button onClick='Themes.setTheme(Executions.getCurrent(),"breeze");'/>
and calling getCurrentTheme doesn't resolve the current theme based on an existing cookie, the list of cookies is empty (in: org.zkoss.zul.theme.CookieThemeResolver#getTheme)
String currentTheme = Themes.getCurrentTheme();
Current Result
java.lang.NullPointerException at org.zkoss.zul.theme.CookieThemeResolver.setTheme(CookieThemeResolver.java:73) at org.zkoss.zul.theme.Themes.setTheme(Themes.java:71)
Expected Result
no exception
Root Cause
websocket connections don't have cookies
Workaround
setting the cookie manually:
String contextPath = Executions.getCurrent().getContextPath(); Clients.evalJavaScript(String.format("document.cookie = 'zktheme=%s;path=%s';", "breeze", contextPath));