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

Window detaches even when calling Event.stopPropagation() in a Composer

XMLWordPrintable

    • None

      According to http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zul/Window.html it is possible to manage onClose event in custom way and prevent the default behaviour (detach the window) from being executed.

      The test provided in the attached files demonstrate that behaviour can't be achieved when using a composer.

      The idea of the test is that the two windows winOk and winWrong will respond to onClose by hiding the window only, so it can be shown later (multiple times) by the "Open Wrong Window" and "Open Good Window" buttons.

      In the case of winOk everything is coded in zscript in test.zul and works as expected, however when trying to implement the same for winWrong in its controller method org.zkoss.test.WinViewCtroller.onClose$winWrong(Event) the window will detach. A subsequent click to "Open Wrong Window" will produce this error:

      08/09/2011 11:53:20 AM org.zkoss.zk.ui.impl.UiEngineImpl handleError:1280
      SEVERE: >>org.zkoss.zk.ui.UiException: Sourced file: inline evaluation of: `` winWrong.doModal();'' : Attempt to resolve method: doModal() on undefined variable or class name: winWrong : at Line: 2 : in file: inline evaluation of: `` winWrong.doModal();'' : winWrong .doModal ( )

      >>Sourced file: inline evaluation of: `` winWrong.doModal();'' : Attempt to resolve method: doModal() on undefined variable or class name: winWrong : at Line: 2 : in file: inline evaluation of: `` winWrong.doModal();'' : winWrong .doModal ( )
      >>
      >> at bsh.UtilEvalError.toEvalError(Unknown Source)
      >> at bsh.UtilEvalError.toEvalError(Unknown Source)
      >> at bsh.BSHMethodInvocation.eval(Unknown Source)
      >> at bsh.BSHPrimaryExpression.eval(Unknown Source)
      >> at bsh.BSHPrimaryExpression.eval(Unknown Source)
      >> at bsh.Interpreter.eval(Unknown Source)
      >> at bsh.Interpreter.eval(Unknown Source)
      >> at org.zkoss.zk.scripting.bsh.BSHInterpreter.exec(BSHInterpreter.java:134)
      >> at org.zkoss.zk.scripting.util.GenericInterpreter.interpret(GenericInterpreter.java:341)
      >> at org.zkoss.zk.ui.impl.PageImpl.interpret(PageImpl.java:876)
      >> at org.zkoss.zk.ui.impl.EventProcessor.process0(EventProcessor.java:180)
      >> at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:138)
      >> at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.process0(EventProcessingThreadImpl.java:517)
      >> at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.run(EventProcessingThreadImpl.java:444)

      The problem happens either when clicking the cross button (available by setting closable="true") or forwarding the onClose event from buttonWrong button.

      In both cases the controller method org.zkoss.test.WinViewCtroller.onClose$winWrong(Event) gets called, I can see the log message as follows:

      11:53:16,269 INFO [Thread-12] zkoss.test.WinViewCtroller.onClose$winWrong(18): Called

      Further testing while debugging my real code (when I first faced the problem), showed that at some point the internal ZK event processing code, there are two instances of the onClose event, one of them gets to the composer where it is sopped from being propagated but later on the second instance gets through to Window.onClose() causing the windows to be detached.

            jumperchen jumperchen
            javich javich
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: