It used to be JSP and JSF for the web pages and embedded java codes and java
objects and servlets behind the scenes. That was all java could do-give you
dynamic pages and you could provide interactivity, page flow and navigation with
more robustness. Then came technologies like AJAX, MXML (if you still have no
clue what the latter is, remember Adobe Flex!) and frameworks such as Ruby on
Rails and what followed, as they say, is history. We won't go deep into what
AJAX is all about and what difference or advantages it brings over pure java
only pages. We will rather zero in on this Open Source project called ZK that
gives AJAX without java script. Smells like GWT (Google Web Toolkit) already?
Well, just read on to find out what it actually is.
The basics
You can download the latest build from the URL mentioned in the box. The
installation is pretty simple, requiring you to simply unzip the package and get
started by adding the 'jars' to your 'Class-path'. The framework has a library
of inbuilt components and a mark-up language known as ZUML (ZK User Interface
Markup Language). This mark up language is based on XUL (XML UI Language). For
more details on XUL and the RICHIE alliance, visit
http://xul.sourceforge.net/mozilla.html. An AJAX-based engine handles the
events, where as, the components' content synchronization is handled by the ZK
engine. One thing worth mentioning here is that unlike JavaScript, the events
are not handled on the client side unless the developer specially provides that
functionality through a component. This is interesting as local handling of
certain events certainly reduces bandwidth considerations; perhaps for the
reason that the creators of the framework believe that while using JavaScript,
you still have to take care of other new issues such as but not limited to
replicating application data across client browser and manipulating DOM on the
browser end.
|
ZUML
This is a rich markup language that allows you to do a lot and if the tags are
not enough you can embed EL (Expression Language) and even use the 'zscript', a
proprietary script provided by the framework. Full marks for page region
updating as it took us just three lines of code to add a label which displays
the value selected in an adjoining drop down list. Other than this, there is a
rich set of attributes that can be used to compact the code further. And if
that's not enough, you can even use the mark-up language to create custom
components. For the religious java programmer who doesn't like playing with
mark-ups, you can create ZK applications using the class libraries provided in
the framework. Using these objects in the libraries available is not that
cumbersome as it is simply writing the code.
The Java Way
If scripts and mark-ups are not your favorite, you can go for a java only way
for creating pages. Let's look into some crucial classes and their methods,
which make up the implicit objects.
The WebApp class represents the application and is the source for the
implicit object 'applicationScope', which executes the 'getAttributes()' method
of this class. Similarly, there are implicit objects such as event based on the
class Event for handling events and their attributes.
Another important interface is Richlet. If you are creating pages without
markup, your java class will be inheriting from classes that implement this
interface-generally the 'GenericRichlet' class. A Richlet creates all components
in response to a user's request. A detailed description of all the classes,
tags, ZUML and sample code is available in the Developer Guides provided with
the project.
In conclusion
Full marks for the excellent framework that provides full liberty to use either
mark-ups or script or even Java code.