October 24, 2016
Hot Topics:

Using Google Web Toolkit to Access SQL Anywhere Web Services

  • December 14, 2006
  • By Rob Close
  • Send Email »
  • More Articles »

This application refreshes its data on a regular interval. A timer is used to regulate the collection of data. The timer needs to start when the application is loaded into the browser's document and stop when the application is unloaded. This block of code demonstrated how I did that:

public void onLoad() {
   _timer = new Timer() {
      public void run() {
         boolean success =
            HTTPRequest.asyncGet( _hostName +
            new ResponseTextHandler() {
            public void onCompletion( String responseText ) {
               _content.setHTML( responseText );
         if( !success ) {
            // Report problem to user.
            Window.alert( "Error getting connection data." );
   _timer.scheduleRepeating( _refreshRate );

public void onDetach() {

Users of the web application don't want to have to set which properties they view every time the application starts up. Settings can be persisted with cookies. GWT has a Cookie class with static methods for setting and getting cookie values. When testing applications that are being served from your own machine, you may have trouble with cookies. Cookies may not work for localhost. If cookies don't work for you with localhost, and your computer is in a domain, try using your computer's fully qualified name instead of localhost.

Here is the completed web application.

Click here for a larger image.

The completed web application.

Click here for a larger image.

The completed web application showing options menu.

Click here for a larger image.

The options dialog for the web application.

If you have ever written JavaScript targeted at multiple browsers, you will know that it can be tricky having everything work as expected in every browser. To get around that problem, GWT generates scripts for several popular browsers. The generated code loads the right script for the browser as it is being loaded. GWT does a nice job of lowering the bar for Java programmers faced with the task of deploying a web application to multiple browsers.

Once you know the steps, getting Google Web Toolkit working with SQL Anywhere is a straightforward process. I don't consider this sample application finished, but I hope it gives you a good start at creating your own applications.


About the Author

Rob Close is a senior developer on the SQL Anywhere engineering team. He is one of the team's Java gurus working on the administration tools for SQL Anywhere. When Rob is not working on the next version of SQL Anywhere or writing technical articles, he can be found tending to his honey farm in southern Ontario, Canada.

Page 3 of 3

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel