0

stopPropagation() from within a ForwardComposer does not work

asked 2010-01-27 08:28:57 +0800

Bobzk gravatar image Bobzk
444 1 8

How come when using the following ZUL -

<zk>
	<window id="mywin" title="Test Hello Window" border="normal" height="200px"
		apply="BobJavaController" width="200px" closable="true"
		sizable="true">
		Hello World Message:
	</window>
</zk>

with the java code (BobJavaController) :-

import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.util.GenericForwardComposer;

@SuppressWarnings("serial")
public class BobJavaController extends GenericForwardComposer {

   public void onClose$mywin(Event event) {
       System.out.println("close");
       event.stopPropagation();
   }
}

The event.stopPropagation has no effect. The window is closed.

If I change the ZUL to :

<zk>
	<window id="mywin" title="Test Hello Window" border="normal" height="200px"
		apply="BobJavaController" width="200px" closable="true"
		sizable="true" onClose="event.stopPropagation()">
		Hello World Message:
	</window>
</zk>

the stopPropagation works and the window does not close. Of course then the java code in BobJavaController is then not called at all.

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2010-01-29 08:03:33 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

public void onClose$mywin(Event event) {
       System.out.println("close");
       Events.getRealOrigin(event).stopPropagation();
}

The event sent to onClose$mywin is a ForwardEvent that you need to get the original one to stop it from propagation.

link publish delete flag offensive edit

answered 2010-01-30 08:03:52 +0800

Bobzk gravatar image Bobzk
444 1 8

Many thanks Henrichten

I new it would be me being stupid and something that I was not doing, so I didn't post it as a bug.

Only slight change is I needed to cast "event" as in :-

Events.getRealOrigin((ForwardEvent) event).stopPropagation();

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-01-27 08:28:57 +0800

Seen: 856 times

Last updated: Jan 30 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More