ZK Framework Tutorials
Frameworks
ZK FrameworkZK-Framework - Creating the Pages
Table of Contents
ZK-Framework - Creating the Pages
Menu Page with Result Page
Redesigned Page
Store data in model classes
Validations
Complete Implementation
Adding textbox component
Toolbarbutton componentZK-Framework - Creating the Pages
Read from beginning sample Chapter 2 - Online Media Library
ZK-Framework - Online Media Library
Setting up Eclipse to Develop with ZK
Setting up a New Project
Creating the Pages
After the implementation of the model classes (which is not in the scope of this book) it's time to start with implementing the ZUL pages. The first page is index.zul which should be a simple navigation page for the individual pages.
A simple way to execute the individual pages is to offer links for each page on the starting page. In a simple HTML page, we would use a href tag. In a ZUL page the preferred way is to use toolbarbutton. With the following line we add a link to add-media.zul:
<toolbarbutton label="Add a new media" href="add-media.zul"/>
We need four navigation points, and therefore, four pages to fulfill the requirements of the CRUD feature. These four pages are:
- Add a new media item: add-media.zul
- Update an existing media item: update-media.zul
- Delete an existing media item: delete-media.zul
- Show media: show-media.zul
The navigation page is depicted in the following figure:

To have a border with a title, the window component of ZK is used. With the help of the div component, the window component is centered. The next problem we have to solve is that each link should appear on a new line. This is achieved by using the br tag from HMTL. Hence, we have to define the XHTML namespace.
The complete implementation of the page is shown below:
- <?xml version="1.0" encoding="UTF-8"?>
- <zk xmlns:html="http://www.w3.org/1999/xhtml" target="_blank" rel="nofollow">
- <div align="center">
- <window title="Welcome to the online media library"
- border="normal" width="300px">
- <div align="left" style="margin-left:30pt;
- margin-top:10pt; margin-bottom:10pt">
- <toolbarbutton label="Add a new media"
- href="add-media.zul"/>
- <html:br />
- <toolbarbutton label="Update a media"
- href="update-media.zul"/>
- <html:br />
- <toolbarbutton label="Delete a media"
- href="delete-media.zul"/>
- <html:br />
- <toolbarbutton label="Show media"
- href="show-media.zul"/>
- </div>
- </window>
- </div>
- </zk>
Next Page: Menu Page with Result Page
Sponsored Links
