There are some traditional applications that could be used to introduce a framework. One condition for the selection is that the application should be a CRUD (Create —Read—Update—Delete) application. Therefore, an ‘Online Media Library’, which has all four operations, would be appropriate. We start with the description of requirements, which is the beginning of most IT projects.
The application will have the following features:
In the first implementation round the application should only have some basic functionality that will be extended step by step.
A media item should have the following attributes:
The most important thing at the start of a project is to name it. We will call our project ZK-Medialib.
We use version 3.3 of Eclipse, which is also known as Europa release. You can download the IDE from http://www.eclipse.org/downloads/. We recommend using the version “Eclipse IDE for Java EE Developers”.
First we have to make a file association for the .zul files. For that open the Preferences dialog with Window | Preferences. After that do the following steps:
The steps are illustrated in the picture below:
With these steps, we have syntax highlighting of our files. However, to have content assist, we have to take care about the creation of new files. The easiest way is to set up Eclipse to work with zul.xsd.
For that open the Preferences dialog with Window | Preferences. After that do the following steps:
Now we can easily create new ZUL files with the following steps:
Now you have a new ZUL file with content assist. Go into the generated attribute element and press Alt+Space.
The first thing we will need for the project is the framework itself. You can download the ZK framework from http://www.zkoss.org. At the time of writing, the latest version of ZK is 2.3.0. After downloading and unzipping the ZK framework we should define a project structure. A good structure for the project is the directory layout from the Maven project (http://maven.apache.org/). The structure is shown in the figure below.
The directory lib contains the libraries of the ZK framework. For the first time it’s wise to copy all JAR files from the ZK framework distribution. If you unzip the distribution of the version 2.3.0 the structure should look like the figure below. The structure below shows the structure of the ZK distribution. Here you can get the files you need for your own application.
For our example, you should copy all JAR files from lib, ext, and zkforge to the WEB-INF/lib directory of your application. It’s important that the libraries from ext and zkforge are copied direct to WEB-INF/lib. Additionally copy the directories tld and xsd to the WEB-INF directory of your application.
Now after the copy process, we have to create the deployment descriptor (web.xml) for the web application. Here you can use web.xml from the demo application, which is provided from the ZK framework. For our first steps, we need no zk.xml (that configuration file is optional in a ZK application).
The application itself must be run inside a JEE (Java Enterprise Edition) Webcontainer. For our example, we used the Tomcat container from the Apache project (http://tomcat.apache.org). However, you can run the application in each JEE container that follows the Java Servlet Specification 2.4 (or higher) and runs under a Java Virtual Machine 1.4 (or higher). We create the zk-media.xml file for Tomcat, which is placed in conf/Catalina/localhost of the Tomcat directory.
<Context path="/zk-media" docBase="D:/Development/workspaces/
workspace-zk-medialib/ZK-Medialib/src/main/webapp" debug="0"
privileged="true" reloadable="true" crossContext="false">
<Logger className="org.apache.catalina.logger.FileLogger"
directory="D:/Development/workspaces/workspace-zk-medialib/logs/
ZK-Medialib" prefix="zkmedia-" suffix=".txt" timestamp="true"/>
</Context>
With the help of this context file, we can directly see the changes of our development, since, we set the root of the web application to the development directory.
I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…
Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…
Once we learn how to deploy an Ubuntu server, how to manage users, and how…
Key-takeaways: Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…
While developing a web application, or setting dynamic pages and meta tags we need to deal with…
Software architecture is one of the most discussed topics in the software industry today, and…