Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-3761

Websocket error when changing the current theme

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 8.5.0
    • Freshly, 8.5.0
    • ZK Update Engine
    • Security Level: Jimmy
    • 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));
      

            wenninghsu wenninghsu
            cor3000 cor3000
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: