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.

alert('Hello '+username.value);<br />

]]><br />

<br />

<br />

<br />

<br />

[ 11 ]<br />

Chapter 1<br />

It was mentioned before that the page contains one hidden button (Say Hello). This<br />

button has the buttonToSayHello id. The idea behind this is that the button is only<br />

shown if there is some input in the textbox with the username id. After the input of<br />

some content (at least one character that is not a white space character) the output<br />

looks like the following screenshot.<br />

One way to define this "event listener" is to define the onChanging attribute for the<br />

textbox username. The implementation of the event is done in Java.<br />

Each main element should have an id attribute. With the id of an<br />

element it's easy to access such an element. In the example, we set the<br />

button visible with buttonToSayHello.setVisible(true).<br />

If we click on the Say Hello button a window with a message is opened (see the<br />

following screenshot).<br />

To show this messagebox the onClick attribute of the button is defined as<br />

alert(&quot;Hello &quot;+username.value). We used the globally defined<br />

method alert to show the message. The parameter for the method is a text string.<br />

We first have a constant Hello text, and then the value of the username (username.<br />

value) textbox.<br />

Always in development, it's important to remember that a ZUL file is just<br />

an XML file. Also if we want to use Java in that file, we have to keep in<br />

mind that some characters could conflict with XML. Therefore, we have<br />

to use the XML entities for special characters. In the example, we used<br />

&quot; for ' and &amp; for the & sign.

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

Saved successfully!

Ooh no, something went wrong!