The methods described at http://books.zkoss.org/wiki/ZK%20Developer's%20Reference/Event%20Handling/Event%20Forwarding do not work when I try to forward Events from composite component that implement IdSpace. I tried some possibilities described at http://forum.zkoss.org/question/77605/cant-capture-events-triggered-from-composite-inside-controller/ and at least I found some tricky way, but this should work more easily. It should be an easy way to forward the events with origin inside the composite component to the composite component itself, and handle the event in the controller of the page where the composite component is used.
I noticed that
this.getPage().getDesktop().getComponentByUuidIfAny("this.getId()"))
returns null in the event handlers inside the component's class. However, with this workaround I can forward the event:
@Listen("onSelect = #cb")
public void onCh(Event evt){
// Always null, why?
System.out.println(
this.getPage().getDesktop().getComponentByUuidIfAny("this.getId()"));
// Workaround
Component target = null;
for (Component c : this.getPage().getDesktop().getComponents()){
if (c.getId().equals(this.getId()))
}
if (target != null)
Events.sendEvent(target, evt);
}