Google Web Toolkit (GWT)
I believe Java UI frameworks, that produce web code (html), are a great alternative to DIY HTML/Javascript libraries. Everytime I look at AJAX web frameworks and libraries, I think many of us are missing the point. Focus on building the application and not tinker with so many frameworks. I think frameworks like GWT will provide a strong alternative in the years to come. Toolset (IDE) support will make or break these frameworks.
After implementing the example, I was amazed at the ease with which I could implement AJAX functionality. In this case the UI periodically polls the backend for stock price changes and updates the section of the page. The code was...
// setup timer
to refresh list automatically
Timer
refreshTimer = new Timer() {
public void run() {
refreshWatchList();
}
};
refreshTimer.scheduleRepeating(REFRESH_INTERVAL);
The refreshWatchList method is shown below...
private void refreshWatchList() {
// lazy
initialization of service proxy
if (stockPriceSvc == null) {
stockPriceSvc = GWT.create(StockPriceService.class);
}
AsyncCallback<StockPrice[]>
callback = new AsyncCallback<StockPrice[]>() {
public void
onFailure(Throwable caught) {
// do
something with errors
}
public void
onSuccess(StockPrice[] result) {
updateTable(result);
}
};
// make the
call to the stock price service
stockPriceSvc.getPrices(stocks.toArray(new String[0]),
callback);
}
Its so obvious what the above code does. Well almost obvious. There are some GWT specific weird stuff you need to do, but thats a small price to pay. Here is an image of the output screen...

The price and change columns periodically update themselves (without refreshing the whole page of course). Here is my complete Eclipse project if you want to try it out. Download StockWatcher






Comments