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

global command binding causes NPE

    XMLWordPrintable

    Details

    • gh.sprint.customfield.default.name:
      ZK 8.6.1 S1

      Description

      Steps to Reproduce

      run the fiddle: http://zkfiddle.org/sample/1ck4p32/4-global-command-handler-causing-NPE

      click the buttons in order: 1, 2

      Current Result

      1 -> replaces a previously include src with a different page
      2 -> causes NPE

      Jan 15, 2019 3:54:55 PM org.zkoss.zk.ui.impl.UiEngineImpl handleError
      SEVERE: 
      java.lang.NullPointerException
      	at org.zkoss.zk.ui.AbstractComponent.getAttachedUiEngine(AbstractComponent.java:373)
      	at org.zkoss.zk.ui.AbstractComponent.smartUpdate(AbstractComponent.java:1851)
      	at org.zkoss.zk.ui.AbstractComponent.smartUpdate(AbstractComponent.java:1825)
      	at org.zkoss.zul.impl.InputElement.setRawValue(InputElement.java:606)
      	at org.zkoss.zul.impl.InputElement$2.setValue(InputElement.java:950)
      	at org.zkoss.bind.impl.PropertyExpression.setValue(PropertyExpression.java:67)
      	at org.zkoss.bind.impl.LoadPropertyBindingImpl.load(LoadPropertyBindingImpl.java:90)
      	at org.zkoss.bind.impl.BinderImpl.doPropertyChange0(BinderImpl.java:480)
      	at org.zkoss.bind.impl.BinderImpl.doPropertyChange(BinderImpl.java:455)
      	at org.zkoss.bind.impl.BinderImpl.access$300(BinderImpl.java:136)
      	at org.zkoss.bind.impl.BinderImpl$QueueListener.onEvent(BinderImpl.java:414)
      	at org.zkoss.zk.ui.event.impl.DesktopEventQueue$QueueListener.onEvent(DesktopEventQueue.java:168)
      	at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:3177)
      	at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3147)
      	at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3089)
      	at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:138)
      	at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1846)
      	at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1618)
      	at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1321)
      	at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:611)
      	at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:487)
      	at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:495)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
      

      Expected Result

      no exception

      Debug Info

      the include initially uses a URI param (-> defer-mode)
      <include id="inc" src="globCommandReceiver.zul?any=param" />

      when replacing the URI (without param) the mode implicitely changes to instant-mode
      <include id="inc" src="empty.zul" />

      Without the initial URI param the problem doesn't happen
      <include id="inc" src="globCommandReceiver.zul" />

      Root Cause

      The child page of Include is not removed/cleaned. So the components are not detached and will keep listening to property changes.
      A side effect of ZK-1148: https://github.com/zkoss/zk/pull/1195/files#diff-aca0546b43d3202fa1b9babc02ec6f2dR914 (DesktopImpl.java)

      Workaround

      • Don't use URI params for includes (avoids defer mode)
      • Set the src to null before setting a new URI
        e.g. <button label="replace include src" onClick='inc.setSrc(null); inc.setSrc("empty.zul");'/>

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 4 hours Original Estimate - 4 hours
                  4h
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day
                  1d