0

ZK Spring 3.0 and @EventHandler

asked 2011-04-08 02:51:06 +0800

christian gravatar image christian
136 2 4

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();
                ....
       }

Where itemListBox is a ListBox-ZUL element that handles selection changes.

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

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2011-04-10 19:51:21 +0800

ashishd gravatar image ashishd flag of Taiwan
1972 6

Hi Christian,
Thanks for your inputs. I have already fixed this and also removed the sop statement. I will release a freshly for this update in this week.

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: 2011-04-08 02:51:06 +0800

Seen: 497 times

Last updated: Apr 10 '11

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