-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5025714
By: troum
There is a button inside listcell. Both elements have onClick event listener.
Problem is that I can't stop propagation button onClick event to cells's event listener. Event.stopPropagation() method doesn't help because event listeners work in different threads.
<window id="test" title="test" border="normal" height="100%">
<listbox width="400px">
<listhead>
<listheader label="1" />
<listheader label="2" />
</listhead>
<listitem>
<listcell span="2" use="org.zkoss.test.TestCell">
<button label="Click" use="org.zkoss.test.TestButton"/>
</listcell>
</listitem>
</listbox>
</window>
public class TestButton extends Button {
public TestButton() {
super();
addEventListener(Events.ON_CLICK, new EventListener() {
public void onEvent(Event event) throws Exception {
Messagebox.show("Buttons's event");
//event.stopPropagation();
}
});
}
}
public class TestCell extends Listcell {
public TestCell() {
super();
addEventListener(Events.ON_CLICK, new EventListener() {
public void onEvent(Event event) throws Exception {
Messagebox.show("Cell's event");
}
});
}
}
Can anybody prompt solution?
Thanks
Sergey
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5025879
By: robbiecheng
Hi Sergey,
Please refer to http://www.zkoss.org/doc/devguide/ch05s02s06.html
/robbie
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5025902
By: troum
hi Robbie, that's just the point that stopPropagation() method doesn't help.
Event still fired for cell element. But processing in another thread
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5026021
By: robbiecheng
Hi Sergey,
I am sorry to tell you that this is a bug, please follow this tracker,
https://sourceforge.net/tracker/index.php?func=detail&aid=1991806&group_id=15276
2&atid=785191
/robbie
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5026030
By: troum
thanks for help
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5026196
By: troum
I've found very uncomfortable solution:
button event listener sends new onUser event to cell (by Events.sendEvent).
This event will be fired before onClick event on cell side. Therefore there is a ability to stop process onClick event.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5027790
By: robbiecheng
Hi Sergey,
Here is a good news for you, the bug has been fixed.
Please download the latest freshly of ZK 3.0.6
Or you could refer to,
https://sourceforge.net/tracker/?func=detail&atid=785191&aid=1991859&group_id=15
2762
/robbie
Hi,
this is Aldo from Italy and my firm uses Zk for a large variety of products.
I have the problem that is listed in this thread, I have a Checkbox and a Radio in a ListItem.
If I click on the Radio or on the Checkbox and I stop the event propagation (in the handler event.stopPropagation();)
the event is still fired to the parent container, the listitem.
I'm using zk 5 and this bug should be fixed since 3.0.6, isn't it?
The only way I can get it work is registering a client side method to handle the client:onClick on the zul file and
make that method fail (since event.stopPropagation() doesnt't work).
It is a very dirty solution but it is the one I've found. But it is a non-solution.
Any ideas?!?!
Thanks in advance!
Aldo
hi,
I think you misunderstand behavior of event.stopPropagation(). It stops the event to be handled by following event handle that register on the same component. It does not stop parent component's event propagation.
so, in your case, stop event for checkbox doesn't stop event for listitem, either.
Asked: 2008-06-12 08:32:34 +0800
Seen: 652 times
Last updated: Apr 30 '12