-
Get a monthly update on best practices for delivering successful software.
I decided to try out GWT on a simple project: providing a small newsletter signup box on a conference micro site. The idea was that after checking that a valid email had been submitted -- and complaining with a DHTML popup if it wasn't -- that email would be sent to a backend web service (asynchronously, of course). While the async XHR request was percolating, the newsletter box would display a thank you message, then fade away. A cookie would also be set, preventing the newsletter box from displaying during the lifetime of the browser session.
This just barely qualifies as AJAX, since I'm doing just one crummy little "Hello World!" communication with the backend. Still, it gets rid of the whole painful navigation to a signup screen, so that's a win in the AJAX column.
OK, so just 150 lines of code later (yeah, I know), I have my little box. The site is software500.pathf.com where you can see the newsletter box in the bottom right corner. Please be kind and don't sign up your goofy friends.
A few lessons from the excercise:
public native void setCookie(String cookie, String value) /*-{ document.cookie = cookie + "=" + escape(value) + ";Path=/"; }-*/; public static native String getLocationHref() /*-{ return $wnd.location.href; }-*/;
In my previous article on GWT Developments, I've pointed out several good resources for getting started, including the GWT newsgroup. Make liberal use of them.
Related posts:
Topics: Ajax Components, Ajax Examples, Ajax Frameworks, Ajax Tools, Design Patterns, Frameworks, Google, GWT, Patterns
discouraging… The last thing I want to do is be writing multi-line Javascript in my Java file… Thanks for the look into it, this is a very valuable blog post and I’ll spread it around.
Comment by Ivan, Thursday, June 15, 2006 @ 6:12 pm