Let us put some interactivity into it.
<window title="Hello" border="normal"> <button label="Say Hello" onClick="alert("Hello World!")"/> </window>
Then, when you click the button, you see as follows.
The onClick attribute is a special attribute used to add an event listener to the component. The attribute value could be any legal Java codes. Notice that we use " to denote the double quot (") to make it a legal XML document. If you are not familiar with XML, you might take a look at the XML section in the ZK User Interface Markup Language chapter.
The alert function is a global function to display a message dialog box. It is a shortcut to one of the show methods of the org.zkoss.zul.Messagebox class.
<button label="Say Hello" onClick="Messagebox.show("Hello World!")"/>
Notes:
The scripts embedded in ZUML pages can be written in different languages, including but not limited to Java, JavaScript, Ruby and Groovy. Moreover, they are running at the server.
ZK uses BeanShell to interpret Java at run time, so you could declare global functions, such as alert, for it. Similarly, almost all scripting language provides a simple way to define global functions, and, sometimes, classes.
All classes in the java.lang, java.util, org.zkoss.zk.ui, org.zkoss.zk.ui.event and org.zkoss.zul package are imported before evaluating the scripting codes embedded in ZUML pages.