Playing with AJAX in NetBeans



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.

I decided to do "all the plumbing" myself, so instead of using a JSF component I revived my old knowledge of JavaScript and in few hours wrote this small app using NetBeans:



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.
Comments:

COOL, Portugal comes first :)

Posted by Daniel MD on červenec 12, 2005 at 12:28 odp. CEST #

Note also that the new blueprints catalog for NetBeans includes an AJAX sample application which does auto completion for city fields in an address form.

Posted by Tor Norbye on červenec 12, 2005 at 03:55 odp. CEST #

Post a Comment:
Comments are closed for this entry.
About

Roman Strobl

Search

Archives
« duben 2014
PoÚtStČtSoNe
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today