- We design and build extraordinary applications for companies looking to make the next great idea a reality.
- learn more
Making GWT JSON not Quite so Painful
I've been using GWT to resurface interfaces of a variety of legacy applications -- J2EE, PHP, Rails -- and more often than not that means working with JSON returned from the server. One thing that I've found is that GWT's JSON support is kind of chatty. That is, you have to write a bunch of code like this:
JSONValue root = JSONParser.parse(json); JSONObject obj = root.isObject(); if (obj != null) { JSONValue map = obj.get("map"); if (map != null) { JSONArray arr = map.isArray(); if (arr != null) { if (arr.size() > 1) { JSONValue strval = arr.get(1); if (strval != null) { JSONString str = strval.isString(); if (str != null) { String s = str.stringValue(); // do something with the string } } } } } }
Yikes! Just to get the string in the second array item in the "map" key of the top level object. Truth is, most of the JSON I'm getting back is fairly predictable. And if it's not in that predictable form, it's an error that the client code can't recover from. I'd like to be able to write something like String result = obj.get("map").get(1).stringValue() without having to worry about NullPointerException's cropping up all over the place.
GWT Tutorial - Building A Model
Shalk Neethling has written up a nice, streamlined tutorial on how to build a model in GWT using the GWTx project's support for java.beans.PropertyChangeSupport.
The basic idea here is that while the browser is the View and the server side is the Model and Controller in MVC, you really should structure your browser side code as an MVC itself where only the Model interacts with the server.
Well worth a read.
Porting Java Libraries - Jazzed About GWT
I've been building GWT interfaces for a while now, and it's been pretty cool. My attrophied Swing skills are slowly coming back and the kinds of stuff I've written has been leagues beyond my early Ajax stuff. So far so good.
Throughout it all, I've been trying to obey my own principle of avoiding leaky business logic and sensitive data. That means that most of the heavy lifting, business logic wise, happens on the server side.
This past weekend, however, I got a rare chance to do some programming for myself. One of my hobbies is chess, and I've written a few programs over the years to help me study and analyze the game. Right now I'm putting the plumbing together for a web/iphone application site. I've got all the stuff that handles FEN, move generation, PGN and UCI (interfacing to chess engines) on the server side, and the application side is mostly concerned with board displays.
Restlet Ported to GWT
If you want to communicate with the server in GWT, you have GWT-RPC and you have JSON (and in fact a few different flavors of JSON). If, however, you pine for the elegance of a RESTful interface, you've had to roll your own.
Now the folks at the Restlet project have ported the Restlet API to GWT.
Thanks to the support for generics in GWT 1.5 RC1, we were able to achieve this port with reduced efforts and limited troubles. We had to get rid of the server-side features that don’t make sense in a browser, and of the APIs like NIO and logging that aren’t emulated by GWT. The major impact was the adaptation of the API to the asynchronous communication imposed by AJAX and GWT.
So now you can make much easier use of RESTful back ends. If you've been working with Rails or Grails, you won't have to ask why RESTful backends are good. If you want a quick intro to Restlets, see this quickstart.
MetaWidget - Convention over Configuration UI
I already know that I'm not going to do MetaWidget justice as I describe it. What the heck is it? According to the MetaWidget site, it is...
Metawidget takes your domain objects and automatically creates User Interface widgets for them, saving you handcoding your UIs and leaving you to concentrate on stitching together your application.
Think of a configurable form widget driven off of your beans through runtime inspection of properties, getters and setters, annotations, etc.
But wait, there's more. It automatically detects your backend at runtime and makes friends with Hibernate, Spring, Seam, Groovy, etc.
Continue reading »
Topics: Android, GWT, JSF, MetaWidget, Struts
GWT IDE Goodness
When GWT 1.5 came out, there was a real deficit amongst the IDE's -- all of them were still in 1.4 land. Well, the situation looks a little brighter today.
- First, there is GWT Tooling, a plugin for Eclipse that is supposed to ease development of GWT applications with Eclipse.
- Next, the folks over at Google are themselves working on their own Eclipse plugin. It's not ready yet, but you can see a presentation from the end of June by Bruce Johnson showing off some the GWT Eclipse plugin's features.
- The latest Cypal Eclipse plugin for GWT is supposed to work for GWT 1.5. Haven't tested it myself yet.
On the disappointment side, Jetbrains looks like it's releasing support for GWT 1.5 in it's 8.0 release. Having to wait for a major IDE release for a plugin upgrade is kind of lame. ![]()
InfoQ Presentation: Building Large Ajax Apps with GWT 1.4 and Gears
Some people like reading tutorials, others love the API docs, still others like listening to presentations. For those who like the latter, here is a pretty decent presentation by Rajeev Dayal of the GWT team.
Topics: Google Gears, GWT
GWT Showcase - BRMS for JBoss Rules
JBoss Rules (the former "Drools," though it's sad to see that cringe-inducing name making a comeback) is a Business Rules Engine (BRE). Those are the logic engines that allow you to execute a large set of "if-then" rules against a large set of facts (the most common algorithm to achieve this kind of performance is called RETE, from the ancient Greek for "net"). For more on BRE's and how to use them, have a look at our Business Rules blog.
One of the things that has differentiated commercial BRE's like Blaze Advisor and ILOG JRules from the Open Source JBoss Rules is the tools. The commercial BRE's were part of a suite of development and management tools -- IDE's, "natural" language support, Business Rules Management Systems (BRMS) -- that made their use in a corporate IT "ecosystem" much easier.
With version 4 of JBoss Rules, you now get a powerful workbench plugin for Eclipse, support for Domain Specific Languages (DSL) that mimick natural language, and a web-based BRMS. With it you can deploy, roll back, and report on your rules.
The BRMS has a nice Ajax interface and is in fact written in GWT. This is a natural for a Java-based system like JBoss Rules. If the developers who use and develop JBoss Rules can also tinker with the BRMS interface (GWT==Java in the browser), the odds are better that the BRMS will evolve apace with the core system.
Compare this with a framework like Echo2/3 where there is only a small cadre of developers who develop the JavaScript piece of what is essentially a Java centric framework, and consequently the development has lagged relative to other frameworks. So, good decision for JBoss Rules and probably a good decision if you are adding a web interface to your own Java system.
Topics: Blaze Advisor, Business Rules, GWT, ILOG JRules, RETE
New GWT Theme: Pinky?
Now that GWT has real themes, we're busy putting some nifty ones together. As I am the least gifted person in terms of visual design at Pathfinder Development, I thought I'd just tweak one of the existing ones -- standard.
So, how did I build my theme? First I created my GWT app with projectCreator:
./projectCreator -out /u1/dkappe/src/RedBlack -ant RedBlack cd /u1/dkappe/src/RedBlack/src # create out package and subdirs mkdir -p com/pathf/gwt/user/theme/redblack/public/gwt/redblack/images/ie6
Then I copied the images and css files from the gwt 1.5 trunk for standard into the directories below public, renaming anything from standard to redblack. There are xml files for normal, RTL (right to left) and "resources," and css files for normal (or left to right) and RTL (right to left).
In my simple style, I flipped blue and red in the images with GIMP and flipped blue and red in the css files by simply flipping the hex values in each of the colors defined in the css. Voila! Red instead of blue. Or actually kinda pink.
Continue reading »
Topics: GWT
A Quick Look at the New GWT “Themes”
One of the welcome developments in GWT 1.5 was the inclusion of some decent looking CSS themes -- standard. chrome and dark.
How can you use them in your GWT app? Just include one of the following lines in your apps .xml file:
<inherits name="com.google.gwt.user.theme.standard.Standard"/> <inherits name="com.google.gwt.user.theme.chrome.Chrome"/> <inherits name="com.google.gwt.user.theme.dark.Dark"/>
You can see them in action in the ShowCase application. For those of you without the patience to kick start the app, here are some screenshots of the new themes:
Topics: Ajax Frameworks, GWT
GWT 1.5 JRE Emulation Additions
OK, one more thing on GWT 1.5: additions to JRE emulation. If you've tried to port some existing Java code into the client, you really feel the absence of some of these. It's still painful, but every bit helps.
New JRE Classes
- StringBuilder
- java.sql.Date
- java.sql.Time
- java.sql.Timestamp
- Enum
- EnumSet
- EnumMap
- PriorityQueue
- LinkedHashMap
- TreeMap
- TreeSet
New methods on existing JRE classes
- Object.getClass()
- Class.getName()
- Integer.bitCount()
- Several additional methods on Class, String and Character
Topics: GWT
GWT 1.5 RC1, Getting Closer
I've been working with GWT 1.5 out of the source repository for a few months, so the release announcements for GWT 1.5 kind of went by unnoticed. But now it's getting serious. GWT 1.5 Release Candidate 1 is out, which means that GWT 1.5 is soon to follow and everyone will soon be enjoying the benefits of 1.5 that I've been relishing for a while. What are some of those benefits?
Topics: Ajax Frameworks, GWT, IDE
6 GWT Resources for the iPhone

- GWT + iPhone == Pretty Tasty - a nice discussion of the development of the GWT Feed Reader for the iPhone and what went into building it. A great starting point if you're just getting started with GWT on the iPhone.
- GWT App Dev for the iPhone - from the GWT Blog, a slightly different take on the GWT Feed Reader project discussed above.
- GWT Feed Reader source code - open source. If you learn best by doing, read the code. See how it's done.
- Fake the iPhone User Agent - testing the iPhone specific versions of sites and apps is easy if you have Mac OS X, but if you don't this quick little tutorial shows you how to fake the User Agent in Firefox.
- iPhone Debug - an attempt to make debugging Ajax on the iPhone easier, sending debugging info back to the server. Uses Jetty with its support for COMET.
- Firebug for the iPhone - the idea that inspired the above. A bridge between your iPhone and the Firebug console in your desktop browser. Now you can see those debug messages in the comfort of your laptop instead of having to do it in the little iPhone window.
I'm going to put together a little bit of a iPhone/GWT howto/tutorial/investigation in the next couple of weeks, starting with a close analysis of the Feed Reader above. Stay tuned.
Topics: Ajax Development, GWT, iPhone
GWT and XUL
There are lots of nice things about writing event-based component GUI applications, but constructing UI's using code is not one of them. It's ugly, messy, time-consuming and hard to maintain. It's also a pain to read, which makes the maintenance even harder.
There are a number of solutions that have been tried over the year -- WYSIWYG roundtrip GUI designer in particular -- but the one I like the most is the XML-based UI description. Much like the DOM trees that you can identify with id's and to which you can hook up event handlers, XML UI markup languages -- XUL, SwiXML, Luxor -- allow you to construct a hierarchical UI with absolutely no compiled code whatsoever. Just write the XML, load it, hook up the GUI to the event handlers and you're ready to rock. And since the XML file configuration, not code, you can write and load different XML files if you feel like changing your UI a bit.
If this sounds like a good idea to you, you'll be happy to know that in the GWT Incubator Joel Webber is developing a project known as DeclarativeUi.
Writing imperative Java code to construct a user-interface hierarchy is awkward, and it makes working with UI designers difficult and/or impossible. What we want is to provide designers (and developers) with a simple way to define the static structure of applications and widgets, without having to write code.
Sound familiar? What does this markup and it's user look like?
Recent Ajax Framework Releases/Developments
Some noteworthy Ajax Framework releases have come out in the last few weeks, along with some other news of interest:
- Ext JS 2.1 and Ext GWT 1.0 Beta - Better performance, new Slider, StatusBar components. REST support (support for other HTTP methods beyond POST and GET). The Ext GWT 1.0 Beta consummates the love affair between GWT (Google Web Toolkit) and Ext that was started by gwt-ext and MyGWT, but provides the comfort of knowing that it is supported by the Ext JS folks. Note: Ext GWT is pure GWT, not an Ext JS wrapper.
- Dojo 1.1 - First off, API compatibility between 1.0 and 1.1. Unified timing loop (ala Scriptaculous) for animation effects, with increased performance. Syntactic improvements to dojo.query. Unification of XHR functionality into dojo.xhr() function.
- Backbase Enterprise Ajax 4.2 - Backbase has been in the commercial framework game longer than almost anyone. Among the new features: hierarchical data bindings and improved performance. If you've wanted data binding for tree widgets, have a look.
- Google Search, Feed and Translation API - I opined a while back that Google discontinued their SOAP search API because they didn't want people reordering or otherwise manipulating their search results. Looking at the terms of use of the new REST service, you can see that this continues to be a concern: You agree that you will not, and you will not permit your users or other third parties to: (a) modify or replace the text, images, or other content of the Google Search Results, including by (i) changing the order in which the Google Search Results appear...
- Google App Engine - it only runs Python apps right now, and it's a preview release available to a select few, but you can already see that this is Google's challenge to Amazon's EC2 compute cloud. In at most a year, unless you are security sensitive -- health care, financial services -- or running on Windows, you won't be building and maintaining data centers. The capital requirements for launching sophisticated and scalable online services is about to change.
- Echo3 (beta) - it's getting close. Superior performance to Echo2. Easier development of new components. Automatic serialization of objects between client and server. All HTML rendering now done on client. Overall the JavaScript client code is now of a design quality on par with the server code.
Lots of exciting developments for Ajax developers and Web 2.0 entrepreneurs. I, for one, can't wait to see how the Google App Engine compares to EC2 for deploying and scaling Facebook applications.
Technorati Tags: ajax, dojo, google app engine, gwt, ext js, backbase, echo3, google search
Topics: Ajax Frameworks, Dojo, Echo2, Echo3, Ext JS, Facebook, Google, GWT, Javascript Libraries
About Pathfinder
Recent
- Roles Testing For Security
- Blackbird takes the pain out of JavaScript logging
- Making GWT JSON not Quite so Painful
- IDEA - preconference workshop 06 Oct 08
- HTML5, Ajax history management, and The Ajax Experience 2008 Boston
- A Look Back At Past Posts
- Flash Player on iPhone gossip
- Microsoft to Jump on Board EC2
- TAE Boston 2008: The Unsexy Presentations
- The Ajax Experience 2008: Hope to see you in Beantown
Archives
- 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


