23.12.2012 Views

ZK Developer's Guide

ZK Developer's Guide

ZK Developer's Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

It's worth mentioning that requests to the same desktop are processed<br />

sequentially, and requests to different desktops are processed in parallel.<br />

That's important if you are using frames, and each frame is a desktop.<br />

Phase: Request Processing<br />

The <strong>ZK</strong> Asynchronous Update Engine updates the appropriate components.<br />

Phase: Event Processing<br />

This is the same as the event processing on creation of a page.<br />

[ 23 ]<br />

Chapter 1<br />

Phase: Rendering<br />

<strong>ZK</strong> renders the affected components. The Client Engine updates the DOM tree on the<br />

browser on the basis of the <strong>ZK</strong> responses.<br />

Events in <strong>ZK</strong>—Listening and Processing<br />

In the introduction to <strong>ZK</strong> with the "Hello World" example, we actually used a way<br />

to register an event listener. We directly defined it as an attribute of a component in<br />

the page:<br />

.<br />

The next way to define an event listener is in the component class. Here, we have the<br />

first use of the use attribute of an element. When using the use attribute, the given<br />

class should implement the base class of the control.<br />

<br />

Now we can implement the event. In the example below, we implement the event<br />

onOK. If the event contains necessary information for the processing it's possible to<br />

give the method an argument org.zkoss.zk.ui.event.KeyEvent. However, the<br />

implementation of the method is correct without the argument, too.<br />

package sample;<br />

import org.zkoss.zk.ui.event.KeyEvent;<br />

import org.zkoss.zul.Window;<br />

public class ExampleComponent extends Window<br />

{

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!