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.

Online Media Library<br />

How to implement a tooltip<br />

One aim in the design of user interfaces should be 'as easy as possible'.<br />

However, the user should also be guided with some help by the<br />

application itself on his or her first touch. One help could be a tooltip<br />

for the elements. For this, most of the <strong>ZK</strong> elements have the tooltip<br />

attribute (e.g: ). The tooltip itself is realized with the help of the popup<br />

component. That means, beyond the tooltip attribute, you have to provide<br />

a popup implementation for the tooltip (e.g. Upload a image for the media.).<br />

Sometimes we may want to provide some error handling for the page, especially,<br />

if we have to add a warning dialog before we really remove a media item from the<br />

underlying persistent storage.<br />

The last screen that we want to implement in the first round is the page for adding<br />

new media.<br />

The following figure shows the page:<br />

How to store data in the model classes<br />

On one side, we have the ZUL page, and on the other side the model<br />

classes. In the case of entering data, the programmer would want to use<br />

the model class directly to store the data. For this, we need some "glue"<br />

code. The <strong>ZK</strong> framework solves that by binding of data with annotations<br />

in the ZUL pages. To use such annotations we have to define a namespace<br />

for them: xmlns:a=http://www.zkoss.org/2005/zk/annotation.<br />

Additionally, we also have to initiate the mechanism of annotation in<br />

the page. This is done with a special init class (org.zkoss.zkplus.<br />

databind.AnnotateDataBinderInit). Now the page is ready to bind<br />

the input directly to the model classes. To bind data, we have to place<br />

an annotation over a normal element (e.g. binds the following input to the name property to object;<br />

note: we have to create an instance object in the zscript block).<br />

[ 56 ]

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

Saved successfully!

Ooh no, something went wrong!