First of all, I would like to apologize everybody for not writing for the last two months or so. I’ve been so swamped with work, that I didn’t even have time to read all my feeds in Google Reader - not even speaking of writing something here. Hopefully now, I’ll find a little more time for that. So without any further ado, let’s get to the topic of today’s post.

Lately, I’ve been doing some work with Grails on a custom back-office application for a medium sized company here in Krakow. The application isn’t very complex - mostly CRUD operations, nothing really complicated. We chose Grails as our Web Framework, because we think it’s ideally suited for this type of stuff (talk about Rapid Application Development…). At some point we decided to add some Dynamic HTML/AJAX features - dynamic grids, that load data from the server without refreshing the page, some animation here and there, some dynamic menus, dialogs etc.

My first JS library (if you can call it that) of choice has been GWT. For some time I’ve played with Ext GWT (I know I bashed it before on this bog, but we didn’t really mind the application going GPL here). What I’ve found out, is that GWT isn’t especially well suited as as sprinkle-on-top solution for “ajaxifying” your site. Don’t get me wrong - I love GWT, it has no match for creating a fat-client JS application: the Swing like UI programming, static typing, all the Java IDE goodness at your disposal, and to top that performance and cross-browser compatibility. Even if I had to program every widget by myself, I’d choose it any day over any other solution. The problems start when you just want to add a little of the AJAX magic here and there in an existing application. In such case, more often than inserting some widget into a div on a HTML page, you want to manipulate the DOM tree. Sometimes you don’t want to have the code that decides what to insert where placed in the GWT module - maybe you want to have some function like insertGridHere() with parameters indicating stuff like URL to take the data from, title of the grid, etc. that could be placed anywhere in the HTML code of your page.

GWT hasn’t been designed with stuff like that in mind - the DOM manipulation API has been only available since version 1.5 RC2, and it only provides some basic DOM manipulation methods - nothing like JQuery, for example. Speaking of devil - a couple of months back Timepedia announced GQuery - a GWT port of JQuery library. I have high hopes for this library, although without commercial support, or even half-decent documentation I don’t think it will be able to take off. I would really like to see people developing plugins for GQuery, like they do for JQuery. You see - the strength of JQuery doesn’t lie as much in it’s excellent support for DOM manipulation, special effects etc. it’s in the plethora of plugins available for it. Want a AJAX-enabled grid control? - there’s like 5 of them. Modal windows, tooltips, accordions? Everything you could imagine is there, and often there’s more than one option to choose from.

Even though I started implementing the dynamic features of my application in GWT, I’ve switched to JQuery along the way. It has it’s disadvantages - I’m never sure if the code I write will run in every browser we want to support (big, big, big disadvantage), the code is not obfuscated in any way (although this can be prevented by using a JS minifier). I also find that I much prefer to organize my code into many little .js files (for better readability), which in turn makes my application initialize slower (I need to use .js packer). The advantages however include having the aforementioned plethora of plugins available at my disposal, each of which is usually designed to be used separately (unlike the usually tightly integrated libraries like Ext GWT). Most of the time the JS code is a lot less verbose than the corresponding Java code I’d have to write to implement the same functionality.

Although for now my first choice for “sprinkle-on-top” AJAX applications is JQuery, I’d really like to go back to GWT. The lack of cross-browser compatibility of the code I write in JS is really annoying. To have the abilities of JQuery, combined with even a friction the number of plugins available for it, and the features of GWT like Java programming language (code organization, code documentation, automatic refactoring, code completition etc.), highly minified and performant code it produces and many other advantages it has, would be a dream come true.

In my opinion GQuery should be adopted by the core GWT team and incorporated into the framework as an addition to the DOM manipulation features it already has. This would probably result a number of plugins springing up to life, and better support for the library. It would also greatly increase the GWT’s abilities to enhance existing web applications. Other than that I’d like to see some kind of ability to define JS libraries in GWT with a public interface, that could be called directly from JavaScript on a HTML page. An interface like that could be probably already defined with a mix of pure JavaScript and JSNI, but why resolve to dirty hacks, when we could have this use-case covered in the core library?

And how about you? Are you using GWT to enhance existing applications? Should GWT even be used for that? What kind of features would you like to see added to the core library, to help you with that task?

Share/Save/Bookmark

Posted in gwt at August 10th, 2008. by Adam 'Psyho' Pohorecki 13 Comments.