GWT Java AJAX Programming 100
simon_kehler writes "The Google Web Toolkit (GWT) is a Java AJAX framework that provides an
easy to use programming paradigm for web developers using the
Java programming language. It is one of the more recent entrants
into this field, but has been gaining a lot of traction and
popularity. GWT Java AJAX Programming authored by Prabhakar
Chaganti and published by Packt Publishing addresses the use of
GWT to build ajaxified user interfaces. The author gently
introduces the reader to GWT and then leads the reader through a
series of tasks, each of which shows how to perform an useful
action with GWT." Read below for Simon's review.
GWT Java AJAX Programming | |
author | Prabhakar |
pages | 240 |
publisher | Packt Publishing |
rating | 8 |
reviewer | simon Kehle |
ISBN | 1847191002 |
summary | A great book for learning the different facets and features of GWT |
I am a software architect working for a startup that is evaluating the use of GWT for a new project. I lead a team of experienced Java developers that are comfortable working with Swing and have reasonable familiarity with Struts. We have looked on with envy at all the nice things you could do with the AJAX integration built into web frameworks in languages such as PHP and Ruby. When I came across GWT we decided to take it for a spin and see if your team would be comfortable using it. The documentation that comes with the GWT download is a bit sparse. I was looking for a more in depth intro to the framework and came across this book. this seems to be the first print book on the GWT framework.
The book is divided into ten chapters. An introduction to GWT and its download and setup is provided in the first chapter. The author then shows how to create random quote GWT application in chapter 2. This is a nice example that immediately gives you the flavor of what its like to work with GWT. It shows you the steps involved in writing and running a simple GWT app. Chapter 3 details the service interfaces that you need to create as a part of any GWT application. These are the heart of how the AJAX mechanism works in this framework. Chapters 4-6 go through a lot of tasks that show you how to create increasingly complex user interfaces using the GWT framework. Chapter 7 deals with creating custom widgets that can be shared across applications. Unit testing for GWT applications is covered in chapter 8 (Yes, you can unit test your AJAX apps!). I18N and client XML support are dealt with in chapter 9 and finally chapter 10 shows how to deploy your applications.
This book moves along at a fairly rapid pace and is a quick read. The examples chosen for the tasks are well thought out and show different features in GWT. There are several really cool and innovative examples in this book: Password strength checker, uses colored check boxes to visually show the strength of a password. A very different way of using a check box. Dynamic Lists, change list entries as selections change. Flickr label, recreates the cool label widget that was made famous by Flickr. Sticky Notes, you create post it notes in your browser and drag them around to place them as you want (uses GWT drag support.) Mona Lisa jigsaw puzzle, rearrange Mona Lisa (uses GWT drag support.) Moo.fx, uses moo.fx javascript library for effects (uses JSNI.) Color Selector, integrates Rico Javascript library into GWT (uses JSNI.) Calendar, a very cool mac os x like calendar widget (Creates a compound widget.) Weather, another widget (creates a compound widget.) I18N, displays the country flag based on the locale (uses i18n support.)
I had played around a bit with GWT before. So some of the things in the book were not new to me, but there were several things that I found very useful. GWT provides a way to integrate Java and Javascript (you can call into Java from JS or from JS to Java) called JSNI (Javascript Native interface). The JSNI examples in this book showed how to integrate with moo.fx, Rico and scriptaculous libraries. This was great as we have some homegrown Javascript libs that we would like to continue to use even when we move to GWT. If we can try to hook those in and call them from GWT, that would be sweet! The ability to create widgets that can be shared across applications is very important to our project. The author creates two widgets in chapter 7 — calendar and weather. Both of these were very cool and reminded me of my mac desktop widgets! The weather widget uses Yahoo's weather service to retrieve the information that is displayed. Again, very nicely done. The ability to unit test is another thing that is crucial for us. GWT leverages and extends JUnit to provide this support. However, this is one of the parts of GWT that people do not seem to be using much. Searching on the GWT forums reveals as much confusion about this topic. This book contains a chapter that shows how to unit test a GWT application. The examples are quite simple, but the creation of test suites was a good one, as I had struggled with that before. I really liked the author's coverage of deployment. He first shows how to manually deploy a GWT application. this gives you a feel for whats involved and what's going where. Then he automates that using ant and finally shows how to deploy from within eclipse. This is very useful as I have tripped over deployment before.
Overall, this is a well written book that was very useful to our team. There were a few examples that we had implemented differently than the author — table sorting, paging and in place editing of the tree nodes. I18N is a big topic and the author covers only one way to use it. It would have been nice to have a complete chapter devoted to that topic, as this is a topic of particular interest to us as we work with a multitude of languages. This is a very developer oriented book and assumes that you know Java, HTML, some Javascript and some CSS. Of course if you did not know those topics, you probably wouldn't be too interested in GWT! This is not a book that dives into the internals of how GWT works or tries to impress you with all the nitty gritty of the GWT architecture. The author provides you with ways in which you can accomplish most common tasks that require GWT. They may not be the only way to do things using GWT but it gets you comfortable using GWT and thinking about how you would actually apply it for your problem. I really enjoyed reading this book and its focus on the practical side of using GWT.
You can purchase GWT Java AJAX Programming from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Web 2.0 (Score:5, Interesting)
Personally, I think it would be nice to see Google work on a standard for 'application markup'. Perhaps lending a few developers to help move the XUL forward.
I can see the benefits of web based applications, but having to write a tonne of script to achieve such a basic HCI function as drag and drop is not whree I want to be.
Re:Web 2.0 (Score:4, Interesting)
I would simply preferr a rethink of the whole web application thing. I mean, I'm *so* tired of having to deal with tons of languages that don't work very well by themselves (imagine work together with others) and are not properly implemented in browsers....etc
I look at old designs such as the Unix with its services (read: small applications) and shell, wich provide the means to have applications interacting with each other in non-obvious ways and it makes me (pardon) sick of having to deal with such a messy place that is web applications.
Frankly, I would be very excited to see a single idiom on server/client side talking to each other without layers of translations and the like, and, of course, fully enjoying the power of scripts on browsers.
IMHO, there are many things wrong when it comes to web app, and I'm not sure the efforts are going in the right direction.
Web 2.0 can be very much like Unix-style programs. (Score:2)
Re: (Score:2)
For a Java developer like me (Who never feels comfortable with Javascripts), GWT is valuable. A swing like UI library like GWT gives you easy RPC and Serialization support. That's all that you need as an applicati
Re: (Score:2)
To bad it uses Java. (Score:2)
I think a domain-specific markup language designed for high power web apps i
Re: (Score:1)
You can use Groovy [codehaus.org] with it, you know =)
Re: (Score:2)
Still, it's not significantly easier IMO than developing with Javascript and CSS so long as you have a framework that's already developed the widgets and worked out the compatibility issues.
Just a side rant.. I have to say that I really hate Internet Explorer. Even IE7 has significant problems with it's Javascript and CSS which require hou
Re: (Score:1)
VS.NET's WebForms does greatly simplify the development of web applications - they behave just like normal WinForms applications -- but you can only select HTML 4.0, Netscape 4.7, IE 4, 5, and 6 (this was back in VS 2003, if I remember correctly).
All of these frameworks are mostly overkill (Score:5, Funny)
Test code:
Re: (Score:2, Funny)
You keep using that word. I do not think it means what you think it means.
(Especially after posting 75 lines of ugly Javascript.)
Re:All of these frameworks are mostly overkill (Score:5, Funny)
For my next comedic number I will solve a quadratic equation.
Re: (Score:1)
Re: (Score:2)
Re: (Score:3, Informative)
Oh, and you do realize that setting window.status no longer works on many browsers? It is considered a security hazard.
Re: (Score:2)
Re: (Score:3, Insightful)
Re: (Score:3, Interesting)
One point of a framework is to standardize the things that you do, and do all the prep work to do them. There are good frameworks (ooh, a compiler that does linking!) and bad frameworks (Yay! Frontpage!). To say that a framework is a bad idea because you might need to work outside it is to argue a vague point. Pick the right framework and that doesn't happen.
Now, if you said GWT doesn't handle that, and provided examples, you may
Re: (Score:2)
For everything else the answer is here [slashdot.org], I don't want to repeat myself.
Re: (Score:2)
Re: (Score:1)
Re: (Score:2)
Re: (Score:2, Insightful)
Re: (Score:2)
Some may need more complex frameworks, but most do not.
Re: (Score:2, Insightful)
Re: (Score:3, Insightful)
Re: (Score:1)
Re: (Score:2)
Re: (Score:2)
Yes, they're a little bloated. So is code written in Delphi, C++ Builder, Visual Studio, etc. Obviously, the more you abstract away the details, the more bloat you get. What you have to evaluate is whether or not you get enough of a benefit from that abstraction. In the GWT's case, that benefit is likely to com
Re: (Score:3, Insightful)
Re: (Score:2)
Re: (Score:1)
Re: (Score:1)
Tho your example may be more security minded, it made me think immediately of Delphi, the most productive app development system I ever used. My favorite feature was the visual form inheritance; with it I was able to visually generate data-aware interfaces in minutes. The only weak link in Delphi for me was the 3rd parties; Borland would release a new version with must-have upgrades and I some important 3rd party widget
Re: (Score:1)
Any good programmer can code whatever subset he requires in the time it takes to understand and work around all the generalisations and limitations in a framework.
These Java guys have all their self esteem tied up in their choice of language and can't bear the thought that there are other ways of doin
Re: (Score:1)
Re: (Score:2)
AJAX is Irrelevant (Score:1, Informative)
view in a web-based billing environment, it's a chore trying to keep the kids focused on the
(perhaps boring) task at hand and keep them using clean, simple, classic CGI programming
techniques. Every so often, someone wants to start using AJAX and automatic form reposting
and a bunch of stuff that makes their code unreadabale and unmaintainable by the rest of the
crew. Invariably, I ask them to describe the problem that
Re: (Score:2)
LoB
AJAX is NOT irrelevant... (Score:3, Interesting)
I think you're crazy. Have you looked at the source code of "classic" CGI pages that do a full form post and then return back to the same page... all the while trying to retain the state of existing fields or refresh the screen dynamically based on a selection? Gimme a break. Go read some of the "classic" source code in Bugzilla som
Re: (Score:2)
Saying you don't need AJAX for anything isn't right. If you really can make your applications more user-friendly and avoid using bloated technol
Re: (Score:2)
Re: (Score:2)
Every so often, someone wants to start using AJAX and automatic form reposting and a bunch of stuff that makes their code unreadabale and unmaintainable by the rest of the crew.
Well, there's you're problem. You shouold never look at the javascript code GWT generates anymore than you should look at the Java bytecode javac generates. Raw javascript might be OK for small applications, but for large, complex, apps it gets increasingly difficult to read, debug and maintain. And you can't build applicatio
My experience with GWT (Score:2, Interesting)
Re: (Score:2)
Re: (Score:2)
However, for my next "clean" Ajax project I think I'm going to give GWT a try. I've don
Re: (Score:1)
Re: (Score:2)
I am in charge of a fairly large web app (hundreds of thousands of lines of Java, JavaScript, and AJAX). I looked into GWT when it first came out - it only took me about 20 minutes of fiddling with the demos to realize that a) This is a great toolkit for basing a web app off of and b) this is a horrible toolkit to tie into.
The things that make GWT so great are what makes it near impossible to integr
Re: (Score:1)
Re: (Score:1, Interesting)
Note that even Google doesn't use GWT for their own services. It's a company they bought, rebranded, and open-sourced.
It seems a cool concept (if you can stand writing Java). But I wonder if *anybody* has written a serious app using it yet.
Re:My experience with GWT (Score:5, Insightful)
Part of the value proposition of GWT is that java is easier to maintain than javascript. There are probably a few javascript monkeys out there who don't know much java that don't agree, but most of the javascript (human written) that I see when I do "view source" out on the web is horrible stuff with negative maintainability.
Re: (Score:2)
And that's a great idea, unless you have account for the fact that HTML/CSS/JS *aren't* application bytecodes.
There are lots of concerns in a web app that aren't there in compiled bytecode app:
1. data/code sharing among pages (number of file read requests, repeated data in every page)
2. incompatibilities among browsers (you
Re: (Score:2)
1. data/code sharing among pages (number of file read requests, repeated data in every page)
2. incompatibilities among browsers (you rely on GWT for browser compatibility, it's frequently not accounting for some rather unobvious details, then you're screwed).
3. GWT goes against MVC as it follows a more traditional "apps and forms" paradigm, which means you're severaly limited in code reuse and separation of concerns in your a
Re: (Score:2)
You know, I'll accept the rest of your comments as I truly don't know GWT well enough to be certain. I evaluated it, saw sufficient hurdles in using it and rejected it.
However, I don't need to look in the mirror and practice self-help exercises to know the obvious. If you've ever inspected the code of the google pages (the main google search page, googl
Re: (Score:2)
You know I refuse to accept you're having sufficient experience with any of this if you'll be talking to me that you must absolutely have browser detection code branching to NEED to test in different browsers.
I've seen my share of out-of-nowhere bugs in browsers trying to interpret code they normally support but fail to render properly, including stuff like Firefox improperly rendering the DOM tree if you nest relative and
Re: (Score:2)
Re: (Score:2)
I created it on my own for personal use (I don't like all of the things Prototype chose to do).
This is the original library [prototypejs.org].
Re: (Score:2)
Re: (Score:2)
Merged the $ and $$ selectors, I dropped the "enumerator" extensions, I altered the way classes are created and so on.. But why are you so intensively interested in what I changed
FYI I change things as I suffer mild to moderate NIH syndrome
Re: (Score:2)
Re: (Score:1)
Look into DomAPI (Score:2)
It's not free for commercial use, but the licenses are cheap. It is a very powerful and robust toolkit, not only does it do AJAX but also has a ton of useful GUI widgets and other core functions.
Re: (Score:2)
Re: (Score:1)
Re: (Score:2)
GWT is open source and accepts external contributions.
the issue of layout (Score:2)
If you like the idea of web programming feeling like writing an applet, GWT is just the thing.
Probably my biggest concern after evaluating it was the layout issue; though I guess the "AbsolutePanel" or that "Instantiations GWT Designer" Eclipse plugin might help... along with hunkering down and learning the damn CSS....
Still, programmatic layout is kind of an odd duck.
Also, is it "easy" to add in 3rd party javascript widgets, per se? Seemed a little akward, or at least un-GWT
Re: (Score:1)
In other words, GWT is dead
Re: (Score:1)
Still, programmatic layout is kind of an odd duck.
Only if you're used to doing it with HTML and CSS. A basic layout often seen in desktop applications is the borderlayout. This layout can not be created with HTML and CSS without the help of javascript (onload and onresize event handlers to keep everything in place). So when you need layout such as these, you need to program them, you can't 'declare' them. Have a look at the demo (Desktop App Clone) on the GWT website to see what I mean.
Re: (Score:2)
I dunno, it seems like even old fashioned tables and CSS might be a more reliable way of accurately reproducing a screenshot into a screen...
"Hello World" with GWT (Score:1)
I'm all for faster and easier development, but when such an app gets stuck on the client side, then you are in a lot of trouble; at first glance, it looks undebuggable (if that's even a word).
Re: (Score:2)
A lot of people don't understamd this technology.
Works for me.
Re: (Score:1)
I prefer Yahoo's YUI (Score:3, Informative)
First, on the page http://developer.yahoo.com/yui/theater/ [yahoo.com] the Yahoo "JavaScript Architect" Douglas Crockford gives some really *excellent* learning presentations on JS and the DOM that convinced me that there are really knowledgable people whos philosophy I like too.
Second, the license is BSD - it can hardly be any more free.
Last, if I have to rely on a framework I want to be sure it stays around. So even if some of the others are nice too and would fit, I must say I trust Yahoo a lot more to stay around and improve their framework - especially since they use it themselves for everything they do.
I also must say that I wasn't impressed at all when I finally tried GMail a few weeks ago, as a regular user of Yahoo mail for all my "public" mail (my own domain has 4000 email addresses left but I prefer Yahoo because of the excellent Spam-filter and only use my own domain-address for close friends) I find the Yahoo mail interface superior and much nicer.
What's more, there's YUI-ext, an extension for YUI (and now available for Jquery too), which provides some great-looking and very functional add-ons: http://www.jackslocum.com/blog/index.php [jackslocum.com]
JBoss Seam with Seam Remoting and AJAX4JSF (Score:1)
Try looking at the above if you need a web-app where you can use AJAX as required, but also require full JEE integration including OR mapping with EJB3/Hibernate and a strong GUI component/event model. It makes the disjoint between the various JEE tiers SEAM-less.
GWT online documentation is sufficient (Score:2)
See for yourself, use the section "Creating an Application from Scratch (without Eclipse)" at http://code.google.com/webtoolkit/gettingstarted.h tml [google.com] (using command line tools).
I keep the GWT "Kitchen Sink" examples source handy to copy CSS, code, etc.
GWT is very cool, especially if you need to build one large application. I must say though, if you j
Re: (Score:2)
IDE tools available as well (Score:2)
Unfortunately AJAX (Score:1, Interesting)
upload tag (Score:2)
GWT in production (Score:2, Interesting)
http://www.ociweb.com/mark/GWT.html#WhoIsUsingIt [ociweb.com]
---
check out => http://traceurl.com/rdS?r=1&l=2 [traceurl.com]
Last Summer of AJAX (Score:1)
Since then, I've moved jobs and settled back into normal web dev. Web 2.0 is a distant memory, a tool to smooth over the mudane page refresh