Monday, February 19th, 2007

ZK Now Supports Javascript, Groovy, Ruby

Category: Framework, Java, JavaScript, Ruby

As promised, the latest release of ZK (ZK 2.3 RC) now supports more languages in zscript than just Java. It now supports Javascript, Groovy and Ruby. Futhermore, you can easily add support for a new language in half a day (maybe with some practice, no?) by extending a simple interpreter class. That’s assuming, of course, that a Java-based interpreter already exists for the language.

For those of you not familiar with ZK, it is a Ajax framework that has you write your application logic on the server-side and treats the browser as a simple display server (as opposed to client-side frameworks that implement lots of application logic in the browser and treat the server more as a collection of web services). You write your application using ZUML, an XML-based markup language, assembling interface components in a way very similar to the desktop GUI component/event driven model. You tie your app logic into the markup language using zscript statements:

  1. <window title="Fileupload Demo" border="normal">
  2.     <image id="image"/>
  3.     <button label="Upload">
  4.         <attribute name="onClick">{
  5.             Object media = Fileupload.get();
  6.             if (media instanceof org.zkoss.image.Image)
  7.                 image.setContent(media);
  8.             else if (media != null)
  9.       "Not an image: "+media, "Error",
  10.                     Messagebox.OK, Messagebox.ERROR);
  11.         }</attribute>
  12.     </button>
  13. </window>

In the sample above, we are using Java as the scripting language. Now you can use Ruby, Javascript or Groovy in it’s place. Realize that scripts written in these languages are executed on the server, not the browser.

Posted by Dietrich Kappe at 9:30 am
Comment here

3.8 rating from 44 votes

Comments Here »

Comments feed TrackBack URI

Leave a comment

You must be logged in to post a comment.