Thursday, May 25th, 2006

GWT AutoCompleter

Category: Component, Google

Greg Longman of Tacos/Tapestry fame loves his IDE, so when GWT came out he decided to give it a go, letting him stay in Java land.

He then wrote up his thoughts on building his first GWT widget, an autocompleter.

He also posted the complete source of the project, and a screencast of the widget.

I definitely see the desire to stay in your programming environment, but it looks like a lot of code for an autocompleter. Don’t compare to the Proto/Script AutoCompleter (although there are some issues with that… such as key bindings that you would expect to work).

Some have compared to Rails’ RJS, but it is important to note the difference. GWT/Script#/XML11/… all let you use Java and some of the APIs to build apps. Some ask you to work with Java only apis such as AWT, others like GWT give you new APIs (*). RJS has created a domain specific language for doing Ajax-y things. The DSL just happens to be in Ruby.

GWT AutoCompleter

Posted by Dion Almaer at 8:40 am

3.2 rating from 53 votes


Comments feed TrackBack URI

I think this quote summarizes opinion of this site visitors:

GWT lets Java developers code Java-ish interfaces in Java and have JavaScript and HTML and CSS come out the other end. Will I ever use it? Hell no. Do I feel like my freelancing web developer business is doomed? Hell no.

You are scared, but don’t be. Javascript is not going away. Now, can you move on and maybe take a look at the benefits GWT (and other technologies) gives to developers?


Comment by Alex — May 25, 2006

That code looks amazingly immense for something relatively simple. Coming straight from a PHP-to-Ruby on Rails switch, Java, C# et al seem bloated themselves – adding all of the GWT abstractions sure doesn’t make it any less so.
I agree completely with the people that have stated that they feel GWT, Script# and whatnot “allow” programmers to avoid having to learn how to program for the Web – doesn’t that kind of smell like GoLive and/or Frontpage generated code full of non-standard additions?

Comment by Asbjørn Clemmensen — May 25, 2006

It’s hard not to be scared by technologies like GWT. I still haven’t made my mind up about it yet but my gut feeling is that it will tend to produce more and more “Visual Studio” type developers than it does good software engineers saving time with good tools. I’m sure in the hands of google engineers it’s a wonderful tool (or anyone who still knows more or less what is happening under the covers), but to the average person does this hurt or help?

Hopefully I’m wrong and this won’t be a tool used for evil, but the levels of abstraction are scary. Java -> Javascript -> interpreted javascript bytecode (at least that’s what spidermonkey/mozilla does I think) -> c++ -> assembly -> machine code. Maybe that’s just one sexy recipe showing the glory of programming abstraction and layering of technologies, but I dunno…Feels wrong for some reason.

Comment by Jesse Kuhnert — May 25, 2006

I’d really like to start porting server framework APIs to GWT. GWT isn’t a replacement for any existing application stacks– it lacks a lot of the fundamental pieces of existing ‘frameworks’, leaving you with rendering and communication facilities– no validation, databinding, flows, etc.

Comment by Jacob — May 25, 2006


There are excellent javascript code out there, but very ugly javascript too. So, that’s not the point, because every technology can be abused.


Comment by Alex — May 25, 2006

The linecount argument is not fair: you are comparing a widget that is supposed to be part of UI library to the use of some other library. You want a fair compare — compare the library code. The Rails autocomplete implementation hides behind itself several thousand lines of Rails, and prototype.js code. Now how’s that for a comparison?

True, the GWT library came without built-in autocompletion and many other widgets. I would give it a bit more time and these will pop up — Greg’s widget is only the beginning.

Comment by Sasha O — May 25, 2006

I find it hard to believe that Rails has thousands of lines of code sitting on top of the prototype autocompleter. The code that tacos uses to wrap the prototype autocompleter is about 100 lines total (including required code for server framework integration).

The tapestry 4.1 code that wraps the dojo ComboBox (aka Autocomplete) is about 20 or so lines of code. Why is that hard?

There’s a fine line between helping people and causing self deception. Is ignorance bliss? Only time will tell….

Comment by Jesse Kuhnert — May 25, 2006

It’s completely guaranteed that the Rails wrapper functions for various javascript (Ajax/Effect) calls are tiny – check out the API documentation and click “View Source”.
All they do is print links – they don’t generate much of anything themselves. Instead they use Prototype, which is entirely different than using Java to *generate* JavaScript, not just output it.

Comment by Asbjørn Clemmensen — May 25, 2006

Wait a second. Who told you it is not possible to create such wrappers in GWT? Look here, some of the components are just wrappers around javascript.


Comment by Alex — May 25, 2006

Who said it wasn’t possible to use GWT this way?

On the other hand, it feels like “bad design” to mix and match two seemingly vastly different programming styles into one API. Ie generative Js vs delegating js.

It is cool that people are wrapping the libraries so easily though. My comments so far are negative on GWT but I can’t discount it completely yet, I’m just waiting to see where it goes and what people do with it.

Comment by Jesse Kuhnert — May 25, 2006

Well I said the autocomplete part is several thousand lines of Ruby (part of Rails) + JavaScript ( + prototype) code, not just Ruby code. So if you factor out the common part of the widget, the widget calling code would be comparable to that of Rails (granted, Ruby code is almost always shorter than Java).

The main issue however people seem to be having with the fact that GWT seems to dilute their hard-earned JavaScript experience. Well tough — things sometime change fast in the technology world. My take, it’s better to join them than to fight them, but YMMV.

Comment by Sasha O — May 25, 2006

I’m sure there was a technical argument in there somewhere, remind me where?

Comment by Jesse Kuhnert — May 25, 2006

Take Rails, JSF, GWT, etc they are all creating APIs that wrap JS libraries. I’m still trying to determine if the RJS approach is better than GWT. The advantages of Java component frameworks within the RJS world is that you can deal with explicit references within the Java language. So you are basically ‘programming’ in GWT, except on the server with a full API stack available to you.

I look at it this way, if you have to make an RPC call, you might as well make a call to the framework itself such that the fact that you send back a collection of DTOs vs. Rendered output is indifferent.

In GWT world, you would actually be organizing 3 steps with the server: the call, the transport/dto, and the updating on the client. The advantage with GWT is that for those cases when the DTO is pulled, you can continue to use the data without secondary requests where the component framework/RJS approach is to primarily send back rendered data.

Comment by Jacob — May 25, 2006

I’m sure there was a technical argument in there somewhere, remind me where?

Somewhere along these lines I suppose:

it feels like “bad design” to mix and match two seemingly vastly different programming styles into one API. Ie gen…
It is cool that people …. My comments so far are negative on GWT but I can’t discount it completely yet, I’m just waiting to see wh…


Comment by Alex — May 26, 2006

Is there any implementation (source code) that uses RPC and a db? that we can look at? I am trying to do that and get a list of keywords from a database to display them in the textbox… I realize that teh database java file must be server side but then? what else to do?

Comment by Richard — August 10, 2006


what kind of license do autocompleter code have?
is GPL, LGPL,…

Comment by javar — September 7, 2006


thanks for sharing your source code. its working great. but how to set autocomplete=off for text box. your drop down hides behind browsers history list box. please help.

Thanks in advance.
Abhishek Nath

Comment by abhishek nath — November 25, 2006

It seems like many of the comments here are stabbing at a qualitative judgment of the framework without really understanding why it was created. You should try it first and then decide, or don’t and trust someone else to decide for you (good luck with that). I have only just started using it and I already see how it is useful. It effectively gives the designer the ability to create cross-platform UIs in a web browser without case-coding, and gives you widgets that you would usually see in rich client development. It was made to make your *own* JS libraries for real applications (not thin-skinned JS framework apps). Unlike many of the all-in-one JS libraries mentioned above, GWT compiles your code into JS in an mildly obfuscated and download optimized format. Using dojo, it takes a noticeable time to load the page – GWT is almost instantaneous. Don’t make the mistake in comparing GWT with another all-in-one JS library – it’s not meant to be one, it’s meant to make JS/DOM usable via programming language to people that don’t speak IE/FireFox/Opera,etc.

Comment by Brent — October 23, 2007

Leave a comment

You must be logged in to post a comment.