Each time traditional web applications talk to the web server, they fetch a completely new HTML page. In contrast, AJAX applications offload the user interface logic to the client and make asynchronous calls to the server to send and receive only the data itself. This allows the UI of an AJAX application to be much more responsive and fluid while reducing an application's bandwidth requirements and the load on the server.
At this point, you've created the initial implementation of the StockWatcher application, simulating stock data in the client-side code. In the following three tutorials, you will learn how to retrieve the stock data from a server.
Note: For a broader guide to client-server communication in a GWT application, see Communicate with a Server.
GWT provides a few different ways to communicate with a server. Which data format you use will ultimately depend on the server you need to interact with.
If you can run Java on the backend and are creating an interface for your application's server-side business logic, GWT RPC is probably your best choice. GWT RPC is a mechanism for passing Java objects to and from a server over standard HTTP. You can use the GWT RPC framework to transparently make calls to Java servlets and let GWT take care of low-level details like object serialization.
To try this out, see the tutorial, Making Remote Procedure Calls.
To try this out, see the tutorial, Retrieving JSON Data. Although this tutorial covers making HTTP requests only for JSON data, the code can be adapted to work with XML data instead.
If you're creating a mashup application that needs to use data from one or more remote web servers, you will have to work around SOP (Same Origin Policy) access restrictions. In this tutorial, you'll use JsonpRequestBuilder to retrieve JSON with padding (JSONP).
To try this out, see the tutorial, Making Cross-Site Requests.
Whether you use GWT RPC or get JSON data via HTTP, all the calls you make from the HTML page to the server are asychronous. This means they do not block while waiting for the call to return. The code following the call executes immediately. When the call completes, the callback method you specified when you made the call will execute.
If you are new to AJAX development, the hardest thing to get used to about asynchronous calls is that the calls are non-blocking. However, Java inner classes go a long way toward making this manageable.
For more information on making asynchronous calls, see the Developer's Guide, Getting Used to Asynchronous Calls