GWT over AJAX 
Thursday, July 10, 2008, 06:49 AM
Posted by Simmya
AJAX Overview

AJAX (Asynchronous JavaScript and XML) evolved in an effort to solve difficult problems, by allowing the browser to communicate with the server, behind the scenes, without having to refresh the entire page. It accomplishes this by using JavaScript to only change that portion of the current Web page that needs to be changed. AJAX can make the user's browser behave more like a desktop application, combining server interaction with far greater performance than traditional server-side languages. AJAX is asynchronous in the sense that the needed data is obtained from the server and loaded without interfering with the display and behavior of the current Web page. The data is requested through use of the XMLHttpRequest object, and typically formatted in XML.

But raw AJAX programming can be quite difficult, partly because AJAX code is typically quite daunting, and partly because Web browsers have implemented JavaScript differently, despite a convergence upon ECMAScript standards, promulgated by the European Computer Manufacturers Association (ECMA). As a result, AJAX programmers can spend much of their development time dealing with incompatibilities among browsers and operating systems.

One of the main problems with Ajax development is that you need to master a large stack of heterogeneous technologies. Depending on the nature of your project (for example, business applications), this can be a great drawback.

In addition, different Web browsers don’t support JavaScript and DHTML in the same way. For example, Microsoft Internet Explorer and Mozilla Firefox handle these technologies slightly differently, you’ll need to deal with this if you want your application to run seamlessly on your users’ PCs.

Although most of the Ajax frameworks available today simplify development work, you still need a good grasp of the technology stack. So, if you’re planning to use Ajax to improve only your application’s user experience—if you’re not also using it as a strategic advantage for your business—it may be unwise to spend a lot of money and time on the technology.

GWT to rescue

Google Web Toolkit (GWT), an open source software development framework that allows the programmer to write Java code, which then gets translated into AJAX code. More specifically, the GWT compiler converts the Java classes into browser-compliant HTML and JavaScript code.

The key idea is that GWT is intended to make AJAX programming much easier — especially for programmers already adept with Java.

GWT provides specific APIs to manage the GUI, internationalization, and XML parsing. It also provides a comprehensive library to manage communication between the client and the server. It uses well-known Remote Procedure Call (RPC) principles implemented by a generic servlet (RemoteServiceServlet), which you can specialize for your own needs. You also can use JavaScript Object Notation (JSON) as the data interchange format for your HTTP messages sent with the GWT HTTPRequest class.

GWT also offers an interface, called JavaScript Native Interface (JSNI), which lets you mix your own hand-made JavaScript code with the code generated by the GWT compiler. JSNI uses the keyword native used by Java Native Interface (JNI) to define your own JavaScript functions. The body of these functions is defined inside specifically formatted comments.

The well-known concepts of GUI programming are available with GWT:

* Widgets, including the usual items (such as Button, TextBox, and CheckBox) and more advanced items such as Tree and Menu Bar
* Panels, which contain widgets, with their own layout (panels and layout aren’t separated as in Swing)
* Events generated by widgets. The listeners must implement specific interfaces.

GWT uses Cascading Style Sheets (CSS). Every widget has its own style, which you can change to meet your needs. You must create your own CSS to overload the defaults defined by GWT.
add comment   |  permalink   |   ( 0 / 0 )


<Back | 1 | 2 | Next> Last>>