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

EventQueue with Group scope throws NPE if publish without subscribe

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 5.0.11
    • 5.0.10
    • General

      EventQueue in Group scope will have NPE in the following condition.
      index.zul

      <zk>
      	<zscript>
      	EventQueue que = EventQueues.lookup("iframe", "group", true);
      	void publish() {
      		String text = tbx.getValue();
      		que.publish(new Event("onGroupTest", null, text));
      	}
      	</zscript>
      	<vlayout>
      		<iframe width="400px" height="600px" src="iframe.zul" />
      		<div>
      			Please type some words into the textbox and then you should see NPE exception.
      			<textbox id="tbx" onChange="publish()"/>
      		</div>
      	</vlayout>
      </zk>
      

      iframe.zul

      <zk>
      	<window title="Iframe" border="normal" width="300px">
      		<zscript>
      		EventQueue que = EventQueues.lookup("iframe", "group", true);
      		que.subscribe(new EventListener() {
      			public void onEvent(Event evt) {
      				lbl.setValue((String)evt.getData());
      			}
      		});
      		</zscript>
      		<textbox id="lbl" value="This is Iframe" />
      	</window>
      </zk>
      

            Unassigned Unassigned
            vincentjian vincentjian
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour
                1h