Saturday, December 13, 2008

RIA and Zkoss

Last week, i read an artcle on direct RIA frameworks like Zkoss. Zkoss was new for me. So, I did some googling around and here are my thoughts on RIA and the related.

Your MVC web application
In a typical MVC application, view and controller do operations for displaying a model (the view part) and handle actions (thats the controller) from views. Views are created by the server and pushed on to a client side browser as HTML.

Why AJAX?
Ajax is a way of making the client - server event based communication better. In Ajax world, a click of a button would fire an event which a client side javascript will send to the server side action class. Action does some processing based on the event and returns a response to the client side javascript. Client script knows how to deal with the response and responds by making the necessary changes in client HTML DOM.



The "BIG" difference is that with AJAX, your server communication has become "SMALL". You don't need to submit the entire client DOM to server side. Send only, what is required for that processing and change only that much on the HTML being displayed in browser. This is a big leap in user experience since user only sees some changes in his HTML file compared to the whole page reload for every action/event. With this as the backbone framework, we can now have richer web GUI controls that deals with small portions of your screen and smaller/quicker request/response to update itself.

All good. Why RIA now?
Before we start talking about RIA and Ajax together, we need to first understand them as two different approaches for solving two big web application problems:- browser/client - server communication and user experience.

Rich Internet Application frameworks have a different take on your typical MVC web application modeling. Fact is, they don't enforce on MVC at all. RIA frameworks can combine coding for view and its event handling mechanism into one physical file, like in MVC1 style. The idea is to combine server side actions (your struts actions or JPF controller) and views (in JSP, HTML, etc.) into one unit and let it access business layer or data layer directly.

Zkoss also lets you define server side event handler files as separate entities. But that definitely is not the intention with which RIAs are being developed.

The best part of RIA frameworks is that client-server communication is invisible to developer and hence the term direct AJAX. This gets rid of all the routine code for AJAX that developer needs to write.



How Zkoss does it!
Zkoss does this in 'zul' files. You need to setup a servlet listener that knows how to deal with 'zul'. As part of your setup, all you need to do is copy zkoss jars to your lib directory and modify your web.xml for Zkoss servlets.

Once this much is done, you can write zsrcipts in zul files. They currently support multiple languages including java and ruby. When you run the app on an app server, these files gets compiled into its client server versions like skeltons and stubs. Just like JSPs, zuls gets compiled into servlets.

A java zscript pretty much will look like JSP scriplets; with the difference that this time zscript is more component oriented and all process related. It is like Swing for Java. This is different in that scriplets are normally used to deal with request variables, or write some dynamic HTML.

ZKoss is not the only RIA out there. GWT from google, FLEX, Silverlight from Microsoft, etc. They all implement and stand for the same solution space.

Having said all the good things, there is one point about direct AJAX that we better be aware of before we adopt them. Since developers don't handle the real HTML and what goes between client and server, debugging in related scenarios can be very painful. However, i believe, once proven to be efficient, RIA frameworks can deliver much better user friendly applications in shorter development period.

I also believe RIA based web applications will be the winner in long term race. This, in view of all the new product trends like FLEX and Silverlight and how the market is so keen on them. Lets accept it! Tomorrow's developer demand won't be for network layer experts; but for product specialists who can quickly convert a business problem to a programed solution. The less routine and house keeping code, the more productive you are. That's when RIA frameworks can help you win.

3 comments:

  1. Hi, this is Robbie from the ZK Team. Thanks for your encouragement. I've forwarded it to Dzone.
    http://www.dzone.com/links/ria_and_zkoss.html

    ReplyDelete
  2. Hi,

    You should take a look at IT Mill Toolkit also.
    It's very similar to ZK. I chose to use it for my project because...
    1) Uses GWT on the client-side (and since I'm not very skilled in Javascript this will be an advantage when I need to customize the client-side)
    2) ITM License is Apache instead of GPL for ZK.

    ReplyDelete
  3. Thanks for the appreciation Robbie.
    Ted, I completely agree with you and i can see why IT Mill Toolkit will be preferred by a hard core Java guy. However, ZKoss can be more productive if one can invest time to appreciate ZScript.

    ReplyDelete