Events of UI Components
To respond to an event, an application must register one or more event listeners to it. Here are the ways to register an event listener:
- By specifying the predefined event handler
onXxxin the markup language.
- By calling the
addEventListenermethod for the component or the page you want to listen to.
- By specifying ZK attributes
apply. Please refer to [ZK_ZUML_Reference/The_ZK_User_Interface_Markup_Language/ZK_Attributes/The_forward_Attribute | The forward Attribute] for more information.
In addition to event triggered by user's activity at the browser, an application could fire events by using
echoEvent methods from the Events class.(Note: These api has to take care about component life cycle, if you use these api outside ZK event handler, please refer to server push.)
How to find out what events a component support
Event Processing is limited to desktop scope
As mentioned above, a desktop is a collection of pages for serving the same URL request. A desktop is also the scope that an event listener could access.
When an event is fired, it is associated with a desktop. ZK separates events by their associated desktops, and pipelines events into separated queues. Therefore, events for the same desktop are processed sequentially. On the other hand, events for different desktops are processed in parallel.
An event listener is allowed to access any component of any page of the associated desktop. It is also allowed to moving components from one page to another as long as they are in the same desktop. On the other hand, it cannot access components belonging to other desktops.