måndag 15 september 2008

I like Google Web Toolkit

It took me some time before i started to play around with Google Web Toolkit but i must say i like. I use Netbeans 6.1 and following these instructions it was extremly simple to set up.

I tried some simple stuff just to start with. For example changing style of text and buttons through the CSS and it was easy. Next thing i wanted to do was to migrate Google Maps with GWT. Unfortually i must say that i was really dissapointed.

First i tried to use Google official Java implementation for Google Maps and it failed. (http://code.google.com/p/gwt-google-apis/wiki/MapsGettingStarted ) I had big troubles with Java Heap Space error and nothing solved this problem.

Next step was to try another library not supported by Google. (http://sourceforge.net/projects/gwt/)
I had some trouble with as well because it used a Long return value in class and GWT gave big NO NO.

Third step was to use native methods in my GWT classes and finally i could start to communicate!

Example code:

final AsyncCallback callback2 = new AsyncCallback() {
public void onSuccess(Object result) {

String position = (String) result;
printLittle(position);
String x = position.split(",")[0].trim();
String y = position.split(",")[1].trim();

setMap1(x,y);
}

public void onFailure(Throwable caught) {
lblServerReply.setText("Communication failed");
}
};
....
private native void setMap1(String x, String y)/*-{
$wnd.setMap1(x,y);
}-*/;


Notice how the native method setMap1 is written.

This made it working and i plan to implement some things i've been thinking about.

I really like GWT, easy to start with and easy to integrate with other javascript.

Next step is to try out Jmaki that comes with Glassfish and see what it can provide.