provides a pure Java, server-centric framework for jQuery-based thin client Web Applications. This page described how the basic application was built. You build ZK applications using only server-side Java, supplying the familiar elements of
- model (data)
- view (html page layout)
- controller (code to populate the view with model data, and respond to user input to read/update the model, and move to new pages)
- Business Logic (typically services, though replaced here by Automated Business Logic)
This project was created in SpringSourceToolSuite (STS) - a variation of Eclipse - beginning with a standard installation of ZK Studio
The key elements are described below.
View .zul (html markup)
You define the view elements as .zul files, which are basically html markup. A view associates itself with a controller with markup such as in line 3:
This sample required about 40 lines of markup.
You then code Java controllers that are responsible for acquiring the data to push into the page, and respond to actions to retrieve new data, update data, and/or move to a new view. We might term this Presentation Business Logic.
The controller is responsible for assuring that updates invoke Transaction Business Logic. It is an anti-pattern to place this logic inside the controller - it should be architected for sharing between controllers and other transaction sources (e.g., message), perhaps in a service.
In a typical database update page, you might expect to find about half of the code as Presentation Business Logic, and half as Transaction Business Logic. In this case, there was nearly 500 lines of Presentation Business Logic. Using traditional approaches
, there would also have been about 500 lines of Transaction Business Logic, though there was none in this case per Automated Business Logic.
Model: Hibernate Domain Objects
ZK is agnostic about how you obtain the model data the controller users to populate the view. In this example, we used Hibernate:
Transaction Business Logic
As described above, we specified the Transaction Business Logic as shown below, replacing 500 lines of Java code. This is explained in the video on the parent page.