Main

AJAX Archives

June 17, 2007

Google Web Toolkit - Build AJAX apps in the Java language

Google Web Toolkit (GWT) is an open source Java software development framework that makes writing AJAX applications like Google Maps and Gmail easy for developers who don't speak browser quirks as a second language. Writing dynamic web applications today is a tedious and error-prone process; you spend 90% of your time working around subtle incompatibilities between web browsers and platforms, and JavaScript's lack of modularity makes sharing, testing, and reusing AJAX components difficult and fragile.

GWT lets you avoid many of these headaches while offering your users the same dynamic, standards-compliant experience. You write your front end in the Java programming language, and the GWT compiler converts your Java classes to browser-compliant JavaScript and HTML.

What is Google Web Toolkit?

Google Web Toolkit (GWT) is an open source Java development framework that lets you escape the matrix of technologies that make writing AJAX applications so difficult and error prone. With GWT, you can develop and debug AJAX applications in the Java language using the Java development tools of your choice. When you deploy your application to production, the GWT compiler translates your Java application to browser-compliant JavaScript and HTML.

Here's the GWT development cycle:

1. 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.
2. 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.
3. Confirm that your application works in each browser that you want to support, which usually takes no additional work.


Why Translate Java Code to JavaScript?

Java technologies offer a productive development plaform, and with GWT, they can instantly become the basis of your AJAX development platform as well. Here are some of the benefits of developing with GWT:

* You can use all of your favorite Java development tools (Eclipse, IntelliJ, JProfiler, JUnit) for AJAX development.
* Static type checking in the Java language boosts productivity while reducing errors.
* Common JavaScript errors (typos, type mismatches) are easily caught at compile time rather than by users at runtime.
* Code prompting/completion is widely available.
* Automated Java refactoring is pretty snazzy these days.
* Java-based OO designs are easier to communicate and understand, thus making your AJAX code base more comprehensible with less documentation.


Google Web Toolkit Features

* Dynamic, reusable UI components
Create a Widget by compositing other Widgets. Lay out Widgets automatically in Panels. Send your Widget to other developers in a JAR file.

* Really simple RPC
To communicate from your web application to your web server, you just need to define serializable Java classes for your request and response. In production, GWT automatically serializes the request and deserializes the response from the server. GWT's RPC mechanism can even handle polymorphic class hierarchies, and you can throw exceptions across the wire.

* Browser history management
No, AJAX applications don't need to break the browser's back button. GWT lets you make your site more usable by easily adding state to the browser's back button history.

* Real debugging
In production, your code is compiled to JavaScript, but at development time it runs in the Java virtual machine. That means when your code performs an action like handling a mouse event, you get full-featured Java debugging, with exceptions and the advanced debugging features of IDEs like Eclipse.

* Browser compatible
Your GWT applications automatically support IE, Firefox, Mozilla, Safari, and Opera with no browser detection or special-casing within your code in most cases.

* JUnit integration
GWT's direct integration with JUnit lets you unit test both in a debugger and in a browser...and you can even unit test asynchronous RPCs.

* Internationalization
Easily create efficient internationalized applications and libraries.

* Interoperability and fine-grained control
If GWT's class library doesn't meet your needs, you can mix handwritten JavaScript in your Java source code using our JavaScript Native Interface (JSNI).

* Google API Library: Google Gears support New!
We are in the process of building support for using Google APIs in GWT applications. Initially, we are providing support for Google Gears, the recently-launched developer product that extends the browser to allow developers to make web-based applications function even while offline. If you would like to download this library please visit the open source project. We are planning to add support for other Google APIs; if you'd like to help, please check out Making GWT Better.

* Completely Open Source
All of the code for GWT is available under the Apache 2.0 license. If you are interested in contributing, please visit Making GWT Better.

Google Web Toolkit Project Home Page
http://code.google.com/webtoolkit/

Download Google Web Toolkit Project Home Page
http://code.google.com/webtoolkit/download.html

GWT Demos & Examples
http://code.google.com/webtoolkit/documentation/examples/

Google Web Toolkit Project Documentation
http://code.google.com/webtoolkit/documentation/

June 18, 2007

Echo2 Web Framework

Echo2 is the next-generation of the Echo Web Framework, a platform for developing web-based applications that approach the capabilities of rich clients. The 2.0 version holds true to the core concepts of Echo while providing dramatic performance, capability, and user-experience enhancements made possible by its new Ajax-based rendering engine.

Echo2 removes the developer from having to think in terms of "page-based" applications and enables him/her to develop applications using the conventional object-oriented and event-driven paradigm for user interface development. Knowledge of HTML, HTTP, and JavaScript is not required. Applications may be hosted using any Java servlet container. Echo2, like its predecessor, is open-source software distributed under the terms of the Mozilla Public License (or, if preferred, the GNU LGPL License).

Module Divisions






The Echo2 framework is divided into three distinct modules: the Application Framework, the Web Rendering Engine, and the Web Application Container. Coupling between the modules are kept to a minimum. The only dependency relationship amongst the modules is that the Web Application Container is dependent upon both the Application Framework and Web Rendering Engine modules. This dependency is NOT reciprocated.

Echo2 Home Page
http://www.nextapp.com/platform/echo2/echo/

Download Echo2
http://www.nextapp.com/platform/echo2/echo/download/

Echo2 Documentation
http://www.nextapp.com/platform/echo2/echo/doc/

Direct Web Remoting - DWR

Direct Web Remoting(DWR) allows Javascript in a browser to interact with Java on a server and helps you manipulate web pages with the results.

DWR is Easy Ajax for Java

DWR is a Java open source library which allows you to write Ajax web sites.

It allows code in a browser to use Java functions running on a web server just as if it was in the browser.

DWR consists of two main parts:

* A Java Servlet running on the server that processes requests and sends responses back to the browser.
* JavaScript running in the browser that sends requests and can dynamically update the webpage.

DWR works by dynamically generating Javascript based on Java classes. The code does some Ajax magic to make it feel like the execution is happening on the browser, but in reality the server is executing the code and DWR is marshalling the data back and forwards.

This method of remoting functions from Java to JavaScript gives DWR users a feel much like conventional RPC mechanisms like RMI or SOAP, with the benefit that it runs over the web without requiring web-browser plug-ins.

Java is fundamentally synchronous where Ajax is asynchronous. So when you call a remote method, you provide DWR with a callback function to be called when the data has been returned from the network.

The diagram shows how DWR can alter the contents of a selection list as a result of some Javascript event like onclick.



DWR dynamically generates an AjaxService class in Javascript to match some server-side code. This is called by the eventHandler. DWR then handles all the remoting details, including converting all the parameters and return values between Javascript and Java. It then executes the supplied callback function (populateList) in the example below which uses a DWR utility function to alter the web page.

DWR helps you in producing highly interactive web-sites by providing some Javascript libraries to help with DHTML and by giving you a set of examples to copy from.

Direct Web Remoting(DWR) Project Home Page
http://getahead.org/dwr

Download Direct Web Remoting(DWR)
http://getahead.org/dwr/download

Direct Web Remoting(DWR) Documentation
http://getahead.org/dwr/documentation