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

Composer doesn't be released when using @Subscribe

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 6.5.1
    • 6.5.0, 6.0.3
    • Container
    • None

      index.zul

      <zk>
      	<label multiline="true">
      	1.when clicking send event, you should see only one message shows in listbox
      	2.after, reload1, reload 2 the window then clicking send event, you should see only one message shows in listbox
      	3.after, detach the window then clicking send event, you should see no message shows in listbox
      	</label>
      	<window>
      		<zscript>
      			int count = 0;
      		</zscript>
      		<include id="inc" src="index2.zul" mode="instant" />
      		
      		<button label="reload 1" onClick='inc.invalidate()'/>
      		<button label="reload 2" onClick='inc.src = "index2.zul?ts="+count++'/>
      		<button label="sendEvent" onClick="sendEvent()"/>
      		
      	</window>
      			<zscript><![CDATA[
      			void sendEvent(){
      				listbox.getItems().clear();	
      				org.zkoss.zk.ui.event.EventQueues.lookup("myqueue").publish(new org.zkoss.zk.ui.event.Event("onMyEvent"));
      			}
      			
      	]]></zscript>
      	<listbox width="600px" id="listbox"></listbox>
      </zk>
      

      ==index2.zul==

      <window>
      	<zscript>
      	java.util.Date time = new java.util.Date();
      	</zscript>
      	<window id="win" title="Hello World!! ${time}" border="normal" width="500px"
      	apply="zkstub.DemoWindowComposer">
      	<button label="detach" onClick='win.detach()' />
      	</window>
      </window>
      

      java

      package zkstub;
      
      import java.util.Date;
      
      import org.zkoss.zk.ui.Path;
      import org.zkoss.zk.ui.event.Event;
      import org.zkoss.zk.ui.select.SelectorComposer;
      import org.zkoss.zk.ui.select.annotation.Listen;
      import org.zkoss.zk.ui.select.annotation.Wire;
      import org.zkoss.zkmax.ui.select.annotation.Subscribe;
      import org.zkoss.zul.Listbox;
      import org.zkoss.zul.Window;
      
      public class DemoWindowComposer extends SelectorComposer {
      	
      	@Wire
      	Window win;
      	
      	@Listen("onCreate = #win")
      	public void onCreate(){
      		win.setTitle(""+new java.util.Date());
      	}
      	
      	@Subscribe("myqueue")
      	public void onQueuEvent(Event queueEvent){
      		Listbox listbox = (Listbox)Path.getComponent("/listbox");
      		listbox.appendItem("["+this+"] get event: "+queueEvent.getName()+"@"+new Date(), null);
      	}
      }
      

            dennis dennis
            dennis dennis
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: