Thursday, May 18, 2006

Google Web Toolkit: Ajax Apps from Java



Google Web Toolkit: Ajax Apps from Java

Google has released Google Web Toolkit (GWT), a code generation framework that lets you code Ajax apps in pure Java. It's not unlike Echo2, the open-source framework from NextApp. A compiler performs the Java-to-Javascript translation.

  • Use your favorite Java IDE to write and debug an application in the Java language, using as many (or as few) GWT libraries as you find useful.
  • Use GWT's Java-to-JavaScript compiler to distill your application into a set of JavaScript and HTML files that you can serve with any web server.
  • Confirm that your application works in each browser that you want to support, which usually takes no additional work.

GWT offers tools for remoting as well as a range of widgets: hierachical trees, tab bars, menu bars, and modal dialog boxes. There's no mention of using these widgets standalone, but hopefully they can be used as pure Javascript widgets in much the same way as Scriptaculous can be used without Rails.

A widget like tree has methods to manipulate the structure (e.g. addItem()) and event handlers (e.g. addFocusListener). Here's how a tree is created:

public class TreeExample implements EntryPoint {

  public void onModuleLoad() {
    // Create a tree with a few items in it.
    TreeItem root = new TreeItem("root");
    root.addItem("item0");
    root.addItem("item1");
    root.addItem("item2");

    Tree t = new Tree();
    t.addItem(root);

    // Add it to the root panel.
    RootPanel.get().add(t);
  }
}
 

 

[via Ajaxian]

0 Comments:

Post a Comment

<< Home