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

Websocket error when changing the current theme

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: Freshly, 8.5.0
    • Fix Version/s: 8.5.0
    • Component/s: ZK Update Engine
    • Security Level: Jimmy
    • Labels:
      None

      Description

      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));
      

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: