-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
i think this discussion is mainly for ashishd, but everyone is free to join ;)
i just stumbled over two problems with the @EventHandler-Annotation in ZK Spring 3.0.
If i have a annotations and handlers from ZK-Spring 2 times looking like:
@EventHandler("itemListBox.onSelect") public void onItemSelected(Event event) { SelectEvent se = (SelectEvent) event; Listitem lastSel = (Listitem)se.getReference(); .... }
With ZK-Spring 3.0 the event given here is not longer the SelectEvent like it was in ZK-Spring 2.0 times, now it's a "ForwardEvent".
I digged into the code and found this code for onEvent in GenericSpringComposer.java:
@Override public void onEvent(Event event) throws Exception { // TODO Auto-generated method stub System.out.println(event.getName()); Event evtOrig = org.zkoss.zk.ui.event.Events.getRealOrigin((ForwardEvent) event); List<String> methodNames = eventsMap.get(event.getName()); for(String methodName : methodNames) { Method md = Classes.getAnyMethod(this.getClass(), methodName, new Class[] {Event.class}); md.invoke(this, event); } }
You get the real / old Event in "evtOrig" which is not used any more, and use the "ForwardEvent" in md.invoke? Is this intended or is this a bug and evtOrig should be used here to maintain ZK Spring 2 compatibility?
I also stumbled over a second issue: I'm overwriting the onEvent-Mehtod in some classes that also get other events. Initially i was forwarding all Events unconditionally to the super.onEvent(), and ran into issues as GenericSpringComposer expects event to be a ForwardEvent.
What do you think, should there be a check added that if the event given is of a different type this method simply returns?
And last but not least: Could you remove the System.out.println() statement? ;)
Or at least replace System.out.println with log.debug ()
Thanks & Bye,
Chris
Asked: 2011-04-08 02:51:06 +0800
Seen: 497 times
Last updated: Apr 10 '11