Interface EventListener<T extends Event>

All Known Subinterfaces:
CloneableEventListener<T>, SerializableEventListener<T>
All Known Implementing Classes:
GenericAutowireComposer, GenericComposer, GenericEventListener, GenericForwardComposer, Selectors.ComposerEventListener, ShowWindowEventListener

public interface EventListener<T extends Event>

An event listener that will be notified when an event occurs, if it is registered to Component.addEventListener(int, java.lang.String, org.zkoss.zk.ui.event.EventListener).

If an event listener also implements Deferrable and Deferrable.isDeferrable() returns true, the event for the listener will NOT be sent to the server immediately (when it is fired at the client). It is called the deferrable event listener. It helps to improve the performance since the deferred events will be 'packed' together and sent to the server at once. It is usually used for event listeners that maintains the application states, rather than generating visual responses.

By default (i.e., if Deferrable is not implemented), the event listener is not deferrable. It is also called the ASAP event listener.

By default, The event listener is invoked after the event handlers registered in a ZUML page (i.e., the onXXX attribute). If you prefer a listener to invoke earlier than the ZUML's event handlers, you could register it with a priority equaling or higher than 1000 (with Component.addEventListener(int, String, EventListener)).

See Also:
Deferrable, SerializableEventListener

Method Summary
 void onEvent(T event)
          Notifies this listener that an event occurs.

Method Detail


void onEvent(T event)
             throws java.lang.Exception
Notifies this listener that an event occurs. To get the event, you have to register it first by use of Component.addEventListener(int, java.lang.String, org.zkoss.zk.ui.event.EventListener) or Page.addEventListener(java.lang.String, org.zkoss.zk.ui.event.EventListener).

If you want to forward the event to other component, use Events.sendEvent(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event).


Copyright © 2005-2011 Potix Corporation. All Rights Reserved. Logo