GWT Java AJAX Programming
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.
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.
I have also looked at GWT and it is pretty innovative. While everyone with ways to abstract the Javascript functions to deliver 'web 2.0', 'ajaxified' applications, Google has treated Javascript, HTML and CSS like the 'byte code' of the web application.
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.
Test code:
You can't handle the truth.
Folk may laugh. There was a time recently when slashdot linked 1MB of script, now it's under 300K and around 70K compressed. Scripts may be cached but first time dialup visitors are still in for a long wait with 70KB of script.
Actually, it's worse than irrelevant - it is a real pain. From a lead programmers point of
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 could not be solved with a
snippet or two of Javascript, and invariably, they start spouting nonsense that basically
boils down to them wanting to fiddle around with AJAX.
If you ever start waking up thinking that perhaps you'll take a gander at AJAX, just repeat
three times: "I do not need AJAX for anything", take your shower, get a nice cup of coffee,
and continue on with your day.
A web app should function without js. Have the kids write things properly and let them add javascript later.
A couple months ago, I was looking into different AJAX frameworks to leverage for an internal web app my group supports. Right now, we basically have a giant tree that is loading about 40,000 nodes from a database at once and then using CSS to show and hide our hierarchy of nodes. This was starting to become inefficient at load time, taking a couple of seconds for the tree to generate and then for the browser to render it. So I started investigating dynamic loading trees using AJAX and then doing a new database call for every node expansion.
First thing I looked at was GWT because I'm a Google fanboy. Their demo seemed great, and we started getting hyped up that our solution was right in front of us. I started tinkering around with the demos, basically hacking their tree demo into something usable for us to get started quickly. Anyways, it didn't take long to find out that to make things worked, everything had to be basically compiled into this horrendous looking Javascript (yes, worse than the usual stuff) that was obviously unreadable (not that was supposed to be). For this and a few other reasons, it didn't take me and a coworker long to realize this was not the solution for us.
I'm sure Google Web Toolkit is great for building a site from the ground up with, but didn't fit into our existing J2EE app very well.
Anyways, if you must know, we looked into the Dojo Web Toolkit and I wrote our tree using that, unfortunately, that framework seems buggy and prone to memory leaks as expanding one node can take much longer than the initial load/render for the CSS tree. We're still using the CSS tree in production, if anyone has any help, let me know! But that's my experience with the Google Web Toolkit. Short and bittersweet.
Reviewing just the first hour of video games.
The short description of GWT is:
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-ish...
SO YOU'RE GOING TO DIE: The Comic for Dealing with Death
Opera's Hallvord blogged a bit about GWT yesterday. He doesn't seem to like GWT much, and neither do I, based on what I've seen there.
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).
http://www.domapi.com/
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.
I was looking for which framework to use. I didn't look (further) at Google's offering because I wanted a JS framework, not Java, so I cannot comment on it. Yet I would like to make a posting to point out my personal favorite, the YUI, and how I got there.
First, on the page http://developer.yahoo.com/yui/theater/ 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
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.
What's your GCNSEQNO?
I thought about buying a GWT book, but the general documentation at http://code.google.com/webtoolkit/documentation/ made it simple to build and modify projects.
h tml (using command line tools).
- in-18-lines.html - my example of trivially adding AJAX support to JSP forms).
See for yourself, use the section "Creating an Application from Scratch (without Eclipse)" at http://code.google.com/webtoolkit/gettingstarted.
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 just need little bits of AJAX, it is trivial using other toolkits (e.g., "Java + AJAX in 18 lines" http://mark-watson.blogspot.com/2007/02/java-ajax
Comment removed based on user account deletion
As you can see on Google itself, there is already some (commercial) support for the GWT. Of course it always helps to know at least the basics of a toolkit even if you start to use an IDE GUI builder. But my experience with e.g. Instantiations is pretty good and the toolkit does not seem too expensive (and, you can see and change the generated code on the fly as well). Of course, if you really go for the GWT for a larger application, you need to know all the bits and bytes and you should at least buy one well written book.
/., please follow up on this.
Note that besides that I do not have any experience with any GWT GUI builder so if there is anyone wanting to share some information with me and the rest of
Unfortunately AJAX has evolved to fill the void: inefficient, ugly, non-standard, and totally counter-intuitive. The reason it is this bad is because the individual components of AJAX were never designed to support rich web-applications; AJAX is a hack. No programmer in their right mind would ever choose to use AJAX over a properly designed remoting and GUI framework. So, why do we tolerate it? Because its currently the only way to build anything that remotely resembles a rich application that is accessible from (most) web browsers. Simply put, its a compromise; however, a very nasty compromise. I pray for the day when people wake up from the buzzword stupor they're in and start demanding better standards.
That's the big thing GWT is missing....clean support for uploading files
SO YOU'RE GOING TO DIE: The Comic for Dealing with Death
To bad GWT uses Java. I wouldn't say that Java is the easiest language to use for rapid development like web applications usually require. Of course the saving grace might be the number of tools that exist to make building GUIs in Java easy. Still, I'd rather see something more RAD oriented than the Java is. It's impressive work even if it isn't perfect though - I think it'll lead the way for better development models in web design.
I think a domain-specific markup language designed for high power web apps is a better idea. Just compile those into HTML/CSS/JS until some browser actually supports the language native. I wonder if XUL and all that Mozilla stuff couldn't be compiled into HTML/CSS/JS the way Google is compiling the Java.
My favorite AJAX trick is still from whomever invented Javascript Behaviors that attach using CSS rules. I use that library constantly and would love to see the concept made into a real standard. I know that when I've developed GUI apps in Java for cellphones I've used libraries that would let you style the UI and attach application logic to the UI using a modified form of css and it really made development easier. With Behaviors my HTML is clean and the application logic is easy to change.
At what price learning? At what cost wisdom? The price is a man's peace of mind, and the cost is his life.
Your comments seem a little odd because web design has become very much like working with Unix-style single purpose programs. If you have trouble it's probably because you aren't coding in Unix-style. My web applications are composed of many smaller programs that each do a single thing. These can be written in whatever language is most appropiate but they speak to each other in common interfaces. My back-end is composed of services that communicate with XML-RPC. The front-end is a thin layer that usually divides the front-end logic between the web server and web browser and all the code is kept mostly seperated. The web server uses PHP for templating, input scrubbing, and calling the back-end services. Most of my code is standard XHTML which if viewed without CSS, Javascript, and the rare bit of Java or Flash looks like very boring circa-1997 content. CSS makes it look nice and Javascript gives it better interaction. The applications work without either of these - they just aren't as nice a user experience. The XHTML, CSS, and JS are kept in completely different places so they are essentially discrete components. Likewise with any Java or Flash I use.
If I have to deal with interfacing with something that doesn't use a XML-RPC interface then I create a service, to sit between it and the rest of my applications, that gives it a XML-RPC interface. I've been recently doing this with Intuit Eclipse which I expect to make programming multiple apps to use much easier. Lots of libraries available, for just about any language, to interface with XML-RPC. Not to many available to interface with Eclipse's IDMS-XML. I've created similar translation services to handle S&H, payment processing, instant messaging, etc. Much easier to maintain than a single massive app.
My web applications are stiched together very much like Unix shell commands. Many small and simple parts that together can do just about anything. If you start mishmashing it all into single files then of course you'll go insane. Using discrete services also makes it a lot easier to divide load across multiple machines and to impose different security levels on different services.
Now if you just wanna bitch about how different browsers handle CSS and Javascript and can join you there. IE7 has helped a lot but I still spend more time fixing issues with IE7 than I do with Firefox, Safari, and Opera combined. Unfortunately, I still have to make sure IE6 at least works even if it isn't perfect.
At what price learning? At what cost wisdom? The price is a man's peace of mind, and the cost is his life.
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 sometime. Talk about coding horror. Go look at the "dynamic" query portion of the Bugzilla search page. (Sidenote: This isn't a knock on Bugzilla developers. You guys did the best with what you had at the time). If Bugzilla's search page was AJAX enabled, it would be worlds easier to read, understand, and maintain.
AJAX programming is so much cleaner. You post only what you need to, when you need to, and then update only the portion of the page that you need to. I don't know how you can say that is more "hard to read" or "a real pain". AJAX programming is the closest you can get to thick-client, event-driven UI programming in a browser. Combine it with JSON and you are talking VERY clean.
I'd love to see examples of what you think "painful" AJAX code is versus the same code in the "classic" CGI paradigm.
In case you are interested, a here is a list of GWT applications in production:
http://www.ociweb.com/mark/GWT.html#WhoIsUsingIt
---
check out => http://traceurl.com/rdS?r=1&l=2
I spent all my last summer looking into the XMLHttpRequest object, Google maps, Local Live, Dojo, prototype.js, and found them to be very resourceful and capable tools for developing web applications. Most useful for FireFox 2 for debugging js. Any programmer can take an idea and make it fly in a matter of weeks (that was my commerical task, find out the possibilities).
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 refreshing we do, like submitting ratings, and quickening the auto-fill bar in answers.com (aka Google suggest?). As for GWT, I found their tools very restrictive. Compared to the flexibility of working with designs directly in HTML/CSS - GWT provided more barriers then solutions for me. Well designed software, written in JavaScript is as effective software written in any other framework GWT, VisualWeb developer, Ruby, etc..
Personally, I would prefer to develop plainly for the web using server side scripts, and add JavaScript as an afterthought. Overuse complicates user experience and muddies the code, which is bad all round. Good website and web application design does not require JavaScript.
Still no proper documentation on dealing with google ajax webkit and 508 or accessiblity
lorem ipsum spamtrap thank you. http://www.geocities.com/testitestitestaaja/