Class GenericEventListener<T extends Event>

java.lang.Object
org.zkoss.zk.ui.event.GenericEventListener<T>
All Implemented Interfaces:
Serializable, EventListener<T>, SerializableEventListener<T>
Direct Known Subclasses:
GenericComposer

public abstract class GenericEventListener<T extends Event> extends Object implements SerializableEventListener<T>

An abstract event listener that you can extend and write intuitive onXxx event handler methods; this class dispatch event to the implemented onXxx event handler methods automatically. It also provides a convenient method bindComponent(org.zkoss.zk.ui.Component) that you can bind a target event component to this event listener easily.

Following is an example. Whenever onOK or onCancel is posted (or sent) to this event listener, it dispatch the control to the corresponding defined onOK() and onCancel() methods respectively. Note how the bindComponent() method bind this event listener to the main window.


 <window id="main">
     ...
 </window>
 
 <zscript><!-- both OK in zscript or a compiled Java class -->
 public class MyEventListener extends GenericEventListener {
    public void onOK(Event evt) {
        //doOK!
        //...
    }
    public void onCancel() {
        //doCancel
        //...
    } 
 }

 new MyEventListener().bindComponent(main);
 </zscript>
 
Since:
3.0.1
Author:
robbiecheng
See Also: