Wire Event Listeners"

From Documentation
Line 15: Line 15:
  
 
=Wire Event Listeners Targeting Fellows=
 
=Wire Event Listeners Targeting Fellows=
 +
 +
To wire a listener for an event targeting one of fellow, you could append the fellow's ID with a separator, $<ref>You could change the separator, if you want, by calling <javadoc method="GenericForwardComposer(char, boolean, boolean)">org.zkoss.zk.ui.util.GenericForwardComposer</javadoc> explicitly.</ref>. For example,
 +
 +
<source lang="java">
 +
public void onClick$btn1() {
 +
    //Called when the fellow named btn1 is clicked
 +
}
 +
public void onChange$inp(InputEvent event) {
 +
    //Called when the fellow named inp's value is changed
 +
}
 +
</source>
 +
 +
<blockquote>
 +
<references/>
 +
</blockquote>
  
 
=Wire Event Listeners in Nested ID Space=
 
=Wire Event Listeners in Nested ID Space=

Revision as of 07:44, 12 November 2010


Wire Event Listeners


Wire Event Listeners

To wire an event listener, all you need is to declare a method with the event name. The method could have an optional argument for the event received. For example,

public void onChange(InputEvent event) {
   //it will be wired and called when onChange is received.
}
public void onMove() {
  //wired and called too, but no pass of the event
}

Wire Event Listeners Targeting Fellows

To wire a listener for an event targeting one of fellow, you could append the fellow's ID with a separator, $[1]. For example,

public void onClick$btn1() {
    //Called when the fellow named btn1 is clicked
}
public void onChange$inp(InputEvent event) {
    //Called when the fellow named inp's value is changed
}
  1. You could change the separator, if you want, by calling GenericForwardComposer.GenericForwardComposer(char, boolean, boolean) explicitly.

Wire Event Listeners in Nested ID Space

Version History

Last Update : 2010/11/12

Version Date Content
     



Last Update : 2010/11/12

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.