Pure GWT - Converting Scriptaculous to GWT
As far as I'm concerned, the main advantage of GWT is the ability to have Java developers write and debug code in, well, Java and their favorite IDE. For those Javascript coders whose blood boils at the mention of GWT, let me offer up a more comforting analogy: when you have lemons, make lemonade. I'll leave aside for the moment the canard that Javascript is a "more powerful language" than Java -- they are both Turing-complete. The notion that one is "more powerful" than the other depends on your perspective. Javascript is great for small libraries but really starts to break down once you build larger systems.
OK, back to allowing Java developers to develop and debug in Java. Right now if you want to use any of the nifty libraries, such as Scriptaculous, in your applications, you have to wrap them using the GWT native trick for including native Javascript (see here for a library that wraps the effects library). If you start experiencing problems with this library, or with its interaction with another library or some code you've written, your Java developers are screwed.
I don't know if anyone recalls the drive for "Pure Java," back when vendors were first exposing their libraries and drivers (e.g. JDBC) as native libraries. The idea was that these hurt portability and thus should be phased out as soon as possible. After all, what was the point of writing Java apps if there was no portability? I propose that we treat the non-GWT Javascript libraries the same way: as a quick way to integrate existing functionality but, for the long haul, something to be phased out because it conflicts with the major advantage of GWT.
I have started on my own modest offering: a rewrite of the Scriptaculous Effects library. I've finished with the effects queue portion and the base effects class. You can see an example of the Fade effect in action here. Note that this doesn't work in IE6 yet, nor Safari, etc. I haven't implemented all of the edge cases that Scriptaculous does. No sweat. That too will come, and the best part is that it can be debugged in Java. Once I get all of the code done, I'll release it under the same license terms as Scriptaculous itself.
The code for the demo EntryPoint is below.
public class Scriptaculous implements EntryPoint {
private Image duke = new Image("images/duke_wave.png");
private Button fade = new Button("Fade");
public void onModuleLoad() {
VerticalPanel vpanel = new VerticalPanel();
VerticalPanel opanel = new VerticalPanel();
opanel.setHeight("150px");
opanel.add(duke);
vpanel.add(opanel);
vpanel.add(fade);
fade.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
Effect effect = new Fade(duke.getElement());
effect.setDuration(2.0);
effect.setAfterFinish(new EffectEventHandler() {
public void handle(Element element) {
DOM.setStyleAttribute(element, "display", "");
DOM.setStyleAttribute(element, "opacity", "1.0");
}
});
effect.enQueue();
}
});
RootPanel.get().add(vpanel);
}
}
As these Ajax applications become larger, the need for a more structured approach such as those offered by GWT (or Tibco GI, in a different way) becomes more urgent. What other Javascript libraries should we convert to GWT?
Topics: GWT, Javascript Libraries
Comments: 5 so far
Leave a comment
About Pathfinder
Follow the Blog
-
Get a monthly update on best practices for delivering successful software.
Subscribe via email
Subscribe via RSS
Categories
Topics
Archives
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
Blogroll
Recent
- Elements of Testing Style
- Aesthetics and Web Design
- Asterisk-Java Testing with Groovy
- 3 Misuses of Code Comments
- Fluently NHibernate
- Digging a Hole and Covering it with Leaves — The Software Development Version
- The Importance of User Experience - Do You Understand It in Your Bones?
- Writing Your Own Protocol With NSURLProtocol
- What’s In Your Dock: iPhone edition
- Feature Fatigue

Obviously Dojo would be a nice lib to convert
Comment by Sander, Monday, June 4, 2007 @ 6:28 am
It was impossible to take the rest of the article seriously, after this statement:
” Javascript is great for small libraries but really starts to break down once you build larger systems. “
There is nothing about Javascript that is more or less unsuitable for large systems. Yes, this is an intentional flat statement.
Of course, you generally do not want to be writing large libraries to download to the browser. This is just classic client/server design - keep complexity on the server and as much as possible push compute work to the clients. Nothing to do with Javascript.
Comment by Preston L. Bannister, Monday, June 4, 2007 @ 12:09 pm
You’re a Google whore. That’s the ONLY reason you’re pimping GWT.
Comment by Douche Bag, Tuesday, June 5, 2007 @ 8:29 am
Hey Nice one there, i agree partially logically that once the code gets bigger you need some structure in there, but if you use ajax only for view purposes , i guess that you dont need much structure there… just a thought.
The libaray i would like to see is JQuery, extJS, mootools.
How long /easy do you think it is to do? what about using groovy?
Comment by bcs06, Tuesday, June 5, 2007 @ 11:22 am
Nice try! Keep up good work!
Comment by Dmitrijs Zaharovs, Thursday, June 7, 2007 @ 3:51 am