Client-side Event Listening"
From Documentation
Line 7: | Line 7: | ||
= Declare a Client-side Listener in a ZUL Page = | = Declare a Client-side Listener in a ZUL Page = | ||
+ | |||
+ | Declaring a client-side listener in a ZUL page is similar to declaring a server-side listener, except | ||
+ | |||
+ | # Use the client namespace, http://www.zkoss.org/2005/zk/client (aka., client) | ||
+ | # It is JavaScript | ||
+ | # Use <tt>this</tt> to reference to the target widget (while the event is referenced with <tt>event</tt>) | ||
+ | |||
+ | For example, | ||
+ | |||
+ | <source lang="xml"> | ||
+ | <combobox xmlns:w="client" w:onFocus="this.open()"/> | ||
+ | </source> | ||
= Register a Client-side Listener in Client-Side JavaScript = | = Register a Client-side Listener in Client-Side JavaScript = |
Revision as of 10:44, 26 August 2010
Overview
ZK allows applications to handle events at both server and client side. Handling events at the server side, as described in the previous sections, are more common, since the listeners can access the backend services directly. However, handling event at the client side improves the responsiveness. For example, it is better to be done with a client-side listener if you want to open the drop-down list when a comobox gains the focus.
The rule of thumb is to use server-side listeners first since it is easier, and then improve the responsiveness of the critical part, if any, with the client-side listener.
Declare a Client-side Listener in a ZUL Page
Declaring a client-side listener in a ZUL page is similar to declaring a server-side listener, except
- Use the client namespace, http://www.zkoss.org/2005/zk/client (aka., client)
- It is JavaScript
- Use this to reference to the target widget (while the event is referenced with event)
For example,
<combobox xmlns:w="client" w:onFocus="this.open()"/>
Register a Client-side Listener in Client-Side JavaScript
Version History
Version | Date | Content |
---|---|---|