Playing with AJAX in NetBeans
By Roman Strobl on VII 12, 2005
Tor Norbye has a great post about using AJAX in Creator with JSF. As he writes there exists a JSF component which can do all the hard work for you. Lots of people are talking about AJAX today so I decided to find out how is actually Google and others using it by writing a small simple application. Btw, did you know that with Google you can use completion like in an IDE? Just try to type in "java.util" - it doesn't work in normal Google but you have to use this link with activated completion. Nice, isn't it?
So you can do pretty cool things with AJAX. While studying it I found this article on java.sun.com which explains quite well how it works. Blueprints are also a good resource of information.
The app is quite stupid. It gives you completion for a list of countries and once you type in a correct country it tells you what's its capital city. It utilizes AJAX to show you list of possible matches - the list is regenerated upon each keystroke. Imagine you would have over 100 countries - a combo box is hard to use in such case. For sake of simplicity I didn't implement browsing of completion's window by arrows (well, the truth is that I'm too lazy to write it, but I have to find an excuse - the countries should be sorted, etc.). You can watch individual requests using NetBeans' HTTP monitor. The advantage for the user is that he gets immediate feedback while he's typing (which leads to better usability of a web app).
Using AJAX you can build a much more rich-client experience than with usual "submit, error, got annoyed, re-submit, got results" web applications. My simple app including NetBeans project is downloadable here - it contains an index page and a servlet, it's as simple as this. To try it out, just open it in NetBeans 4.1 or later and run it. The web is not a good medium for delivering rich client experience yet but with such technologies it may get there once... maybe.