Monday, May 18, 2009

Google App Engine for Java, GWT and GXT

Introduction

With the launch of the new Google App Engine (Beta) delivered with an Eclipse plugin managing GAE and GWT1.6, it is now very easy to deploy new GWT applications in the Google cloud.
GXT is a java library for building rich Internet applications with GWT. As demonstrated on their Web site, this library provides a huge quantity of graphical components to help you creating applications very quickly.

My objective was to evaluate how easy it is to deploy a basic application combining GAE-1.2.1, GWT-1.6.4 and GXT-2.0-md01.

Steps to create the application

Downloading and installing the GAE SDK-1.2.1

This step is done without any problem.

Installing the Eclipse Plugin for GAE

The Eclipse Plugin for GAE is easy to install as well and adds 3 buttons in the toolbar.
image

The contextual menu is modified as well to add a a Google entry

image

Those 3 buttons are used to:

  • Create a new GAE application. You can choose to use GWT, GAE or both. image
  • Compile the code (transform the Java code in JavaScript)
  • Deploy your application on the Google App Engine servers.

Adding the GXT2.0-md01 jar library

You simply need to add an external java library in the project.

image

Coding the application using GWT and GXT

No remark in this section, no specific think related to GAE.

Compiling and deploying the application

Of course, you need to have a developer account to deploy your application.
Before deploying the application, you need to enter the applicationId obtain on the GAE web portal

image image

After entering this information, you only need to click on the image button from the toolbar. A popup appears asking you to fill your Google password. If all is OK, you should visualize your application on a Web browser.

Remarks and problems

For a basic application, there is really no problem, compilation and deployment is working fine. For a more elaborated application with GXT library, problems can occurs.

StackOverflow error during compilation

You need to click on the Advanced link and add the –Xss16M VM argument.

image

Max number of files and blobs is 1000

Your application can use a lot of static files for images, CSS, and JavaScript. When the number of files is greater than 1000, the deployer fires an error.

image To avoid this problem, you need to reduce the number of static files included in your application.

Multiple options are available:
  • Locating your static file in an other Web server
  • Zipping the static files and serving those zipped files with a Servlet included in your application. This solution is working fine for development process but can not be used in a production solution. A link with a sample code is available ">here.

Other remarks

  • During the tests i need to connect behind a proxy. The Eclipse proxy configuration needs to be used to deploy the GEA with a proxy.
  • GAE can be used with an ant file available here. This build file does not include the target to compile the GWT code. To compile the GWT code with this build, you need to add the gwtc target section.

image

Conclusion

This post explains very quickly the main steps to create an application with GWT, GAE and GXT. The Eclipse Plugin is well designed and the application development is easy. I will try to continue playing with all capabilities provided by the GAE (database, …)

Sunday, May 17, 2009

Location with the IPhone Safari browser (SDK3.0)

Introduction

In a previous article, the Google Gears geo-location technology has been introduced to demonstrate how to retrieve the location from the Internet browser.

The IPhone SDK3.0 is introducing a W3C standardized location API in the Safari browser. Objective of this post is to evaluate this JavaScript API provided by the Mobile Safari browser.

I have found the following information from the Apple Web site:

  • A PDF document providing information regarding geographic location classes.
  • A podcast describing the JavaScript location API.
    image

IPhone Web application illustration

A very basic IPhone WebApp is developed to test the JavaScript API.
The WebApp.Net micro framework has been used for this evaluation.

The application is containing the JavaScript code used to retrieve the location. This code is located in the <script> section of the HTML page. As you can see, 3 JavaScript functions has been used and any JavaScript import or other configuration is required.
You can call directly the navigator.geolocation.watchPosition function without any initialization…the navigator object is already known by the Safari…

  • getCurrentPosition returns the current position in the displayLocation callback.
  • watchLocation is used to track the IPhone location. Each time a new location is available, the displayLocation callback is triggered. This method is returning a watchId used to stop the tracking.
  • clearWatch is used to stop the tracking started with the watchLocation.

image

The getCurrentPosition and watchLocation can have up to 3 parameters in input:

  • The success location callback is returning a Position object.
    image
    I have only checked that longitude, latitude and accuracy was returned, i need to complete the tests for altitude and speed. For the heading (direction) i think that this information is not returned with the current IPhone.
  • The error callback is returned in case of error image
  • The PositionOptions object has 3 parameters image

Starting the WebApp

When starting the application for the first time, the Safari browser displays a popup. You need to confirm that you agree to give your location. After multiple uses, the popup does not appear anymore.

In this sample application, the location is displayed in a popup.

image image

Conclusion

The W3C standard API provided with IPhone 3.0 SDK is very easy to use and provides a position through multiple sources (GPS, WIFI, BTS…).
Any Geocoding API is provided by Safari to retrieve an address from this location.
This interesting feature is available with the Google Gears API…
During my evaluation (with the Beta version), the Safari browser was frozen multiple times and i need to restart the mobile…

The application sample will be available in a near future…

GeoLocation with Google Gears and GWT

Introduction

Geo-location is used and available everywhere and it exists multiple solutions to retrieve the position.
Computed position is more or less accurate regarding the technology used.

  • Basic handsets can retrieve the location thanks the operator base stations.
  • GPS handsets can retrieve a more accurate position with GPS or AGPS technologies.
  • When GPS signal is to limited and WIFI available, WIFI positioning can be used...

More and more applications are available with location capabilities.
Those applications are used to find the nearest restaurant, cinema.
Big companies are launching new services to locate your friends (Google Latitude)…

To create those applications, a location API is required to get the handset or laptop position.
The main features of those API are:
  • Returning a position (longitude, latitude, speed) taking abstraction of the underlying technologies (GPS, WIFI, BTS...)
  • Returning the response accuracy.
  • Tracking the handset(return multiple location each time a modification is observed)

This article will focus on the location API's available for PCs and laptops Internet browsers(Safari, IE, Firefox) and more especially on the Google Gears technology.

Google Gears

Google is proposing the Gears API for Geo-Location purpose.

This Google API like the majority of other APIs is returning the position BUT can in addition return geocoding information like the country, city, street number, street and region information.
After installing this plugin, web applications have the possibility to retrieve the location from the Internet browser.
A very basic JavaScript API is proposed to fulfill the main location features exposed previously.

For people familiar with the Google Web Toolkit framework, this Gears API is available as a GWT module.

Next part of the article will demonstrate how to use this GWT Gears API.

To create a web application with GWT and Gears, you need:

  • Download the Gears plugin available Here
  • Download the Gears GWT module available Here
  • Create a basic GWT application with Eclipse or other Java editor

The GWT-Gears Java code

Retrieving the GeoLocation service from the Gears factory

image

To retrieve the current location, you can use the getCurrentPosition method. As you can see in the code, options can be used to specify the accuracy.

If you want to retrieve the address information determined from the longitude and latitude, you need to set the gearsRequestAddress to true. By default, the geocoding is disabled.

image

If you want to be notified each time the location is modified, you need to use the watchPosition method. This method is returning an identifier used to stop the tracking.

image

If you want to stop the tracking (started with the watchPosition method), you need to call the clearWatch method.

image

Conclusion

The Google Gears API (available as a JavaScript library or a GWT module) is very easy to use and provides interesting geocoding features to retrieve Address information.

A W3C standard available here is describing an API for location for Web browsers. The Google API seems very closed from this specification.

In a next article, an overview of the IPhone3.0 Safari location API will be exposed.

Frederic shared items