GWT Tutorial with Googlipse

[Update - A recent revision of this tutorial is available at here.

This tutorial introduces you to GWT. You can do develop GWT apps without any IDE, but it is really helpful if you use one. I choose Eclipse with a plugin for GWT called Googlipse to walk thru this tutorial. Not because Eclipse & Googlipse are free or because Eclipse is the default Java IDE for many developers, but simply because I'm the creator of the Googlipse plugin :-P


Requirements:




  • You need the latest GWT. You can download it at here. Make sure you download the latest version.

  • Download and install Eclipse 3.2 with WTP 1.5. You can get it here.

  • You need a Java 1.5 VM to run Googlipse. You can get it here.

  • Download Googlipse from here and drop in the jar in your eclipse\plugins directory.



Settings:


Before you start, you need to tell Googlipse where you have installed GWT. In Eclipse, select Window -> Preferences -> Googlipse -> Browse. Select the directory where you have installed GWT.



Creating the App:


Create a new Dynamic Web Project. (File-> New -> Project -> Dynamic Web Project)


In the first Wizard page, type "Hello World App" for Project Name and select "Default Googlipse Project" in the Configurations drop down. Click Finish.


With GWT you organize your code as Modules. Modules are typically organized under a package. When you create a module, you will have




  • A <module name>.gwt.xml file, where you will have all your configurations of a module

  • A folder named "public", where you will have all your html, css, images, etc

  • A package named "client", where you will have all the client side code - which will be converted into JavaScript later

  • A package named "server", where you will have all the server side code - in form of Servlets


Select File-> New -> Other -> GWT Module


You can select an existing package if you have already created, or create a package where you want to keep your module. Type "MyModule" for Name and click Finish. In the Package Explorer view, you can see that all the necessary code to run a module is created by Googlipse for you. Now you have the basic skeleton of a GWT app, lets run the app in hosted mode.


Running in Hosted Mode:


Googlipse integrates GWT hosted mode into Eclipse in a nice way. Select Run -> Run -> GWT Application. Click the "New Launch Configuration". You can select the project and the module, which you want to run. In the parameters page, you can customize the options passed to GWTShell. Click Run. You should see two windows popping up. One is the GWT Shell and the other is the hosted browser. Click the 'Click Me' button in the browser window, and you can see the "Hello World!" message right next to the button.



Compiling the application to JavaScript:


You can compile the client code into JavaScript, so that you can deploy it on any standard WebServer. Click the "Compile/Browse" button in the hosted mode browser. This will compile create the javascript and other supporting files under the build\gwtOutput directory.



Deploying to an external server:


Open the Servers view (Window -> Show View -> Other View -> Server -> Servers). Configure your favourite WebServer in the view (Right click on the view -> New -> Server) You can configure any server (Weblogic, JBoss, Tomcat, etc) and the configuration depends on the vendor and its not described here. Assuming you have configured a server, say Weblogic 9.0 server. Right click the configured server -> Add and Remove Projects. In the dialog box, move our Hello World App from Available Projects to Configured Projects and click Finish. Now you can start the server and see your application @ http://localhost:7001/Hello_World_App/MyModule.html (The URL varies depending on the server vendor and the server configuration)



Creating a WAR file:


Creating a WAR file for deployment is very simple. Select File -> Export -> WAR file and follow the wizard.



Adding RemoteServices:


What we have done so far is a simple static application. There is no RPC involved. GWT supports a properitary mecahnism thru which the client code and server code communicate. The heart of the RPC is a RemoteService interface. This lies in the client package of the module. The implementation of this interface should be available in the server package. By convention, the class is named as <RemoteService>Impl and Googlipse enforces this. There is another interface called the Async interface. Async interface is based on the RemoteService interface. More details about this interface is available here. We don't have to worry about this interface, because Googlipse create this Async interface for you and will maintain it.



Select File -> New -> Other -> Gwt Remote Interface to create a RemoteInterface. You need to select the module where it will reside and then give the name and uri. Uri is typically where the client will be looking for the the server code. It should be unique within the given application. Click Finish and you see the RemoteService and RemoteServiceAsync are created in the client package and the RemoteServiceImpl is created in the server package. The RemoteService interface also has an inner class Util with one method getInstance. This will be very handy for invoking the service from the client code. We will see this later. Now lets add a method in the interface:


String sayHello() throws Exception;


You can see Googlipse will update the Async interface with this method signature


 


void sayHello(AsyncCallback callback);


Basically it removes the return type and exceptions and adds the callback parameter at the end of the parameter list.


In the Impl class, implement this method



public String sayHello() throws Exception {
return "Hellooooooo";
}


Invoking RemoteServices:


From the client code, you can use the getInstance method to invoke the RemoteService.



I've modified the MyModule.java to have an RPC call:




button.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
MyServiceAsync instance = MyService.Util.getInstance();
instance.sayHello(new AsyncCallback(){


public void onFailure(Throwable error) {
Window.alert("Error occured:"+error.toString());
}


public void onSuccess(Object retValue) {
Window.alert("Server returned:"+retValue.toString());
}
});
}
});


As you can see, the onFailure method is called whenever there was any problem with the RPC call. If everything goes fine, onSuccess method is called with the return value from the method.



Common problems:




  • I installed Googlipse and nothing happened.


There are 2 possible reasons:

1) You are running an Eclipse 3.1 or earlier.

2) You are running Eclipse on a Java 1.4 VM or earlier




  • How do I change the URI of the application?


Right click the project -> Properties -> Web Project Settings. Change the Context Root value




  • I added the Googlipse facet to an existing Dynamic Web App. Nothing works.


Follow these steps for adding the Googlipse facet to an existing app:



    • First remove the gwt-user.jar from the application build path

    • Remove gwt-servlet.jar from WEB-INF\lib directory

    • Add the facet

    • Open .settings\org.eclipse.wst.common.component file and for every module in your application, add the line

    • <wb-resource deploy-path="/" source-path="/build/gwtOutput/com.googlipse.testApp.MyModule"/> where com.googlipse.testApp is the package and MyModule is Module name.

    • Refresh the application.






  • I upgraded from previous version of Googlipse. I'm getting some errors.


You have to uninstall the Googlipse facet and then follow the above steps to install the facet again.

 

Posted in Labels: | 10 comments

Vettaiyadu Vilaiyadu

'காக்க காக்க' மாதிரி ஒரு படம் எடுக்கலாம்னு கமல் கெளதம் கிட்ட சொல்லி இருப்பார் போல. கெளதம் கஷ்டபடாம அந்த படத்தையே கொஞ்சம் அங்க இங்க மாத்தி remake பண்ணி இருக்கார். நேர்மையான போலீஸ் அதிகாரி, நீளமான தலைமுடிய விரிச்சுப் போட்டுட்டு ஒரு வில்லன், அவர் மனைவியை கடத்திட்டு போற கிளைமாக்ஸ், etc, etc.

படத்துல சொல்லும் படியான விசயங்கள்:

கமல்: சொல்லிக்கவே வேணாம். ஒரு கம்பீரமான போலீஸ் அதிகாரி எப்படி இருப்பாரோ அப்படியே இருக்கார் - கொஞ்சூண்டு தொப்பையும் சேத்திதான் சொல்லறேன் ;-)

கேமரா: சும்மா பூந்து விளையாடி இருக்கார் ரவிவர்மன்.

இசை: பின்னனி இசைல கொஞ்சம் கடிய போட்டாலும் பாட்டுல பட்டய கிளப்பிட்டார் ஹாரிஸ் ஜெயராஜ்.

காமெடி: ஒன்னு ரெண்டு இடத்துல அங்க அங்க டயலாக்ல தூவி விட்டிருக்கறது, ரசிக்கும் படியா இருக்கு. ("மணிரத்னம் படம் மாதிரி பேசறீங்க?", "சாப்ட்வேரா? நானா?", etc)

கோட்ட விட்ட மேட்டருக:

திரைக்கதை: இன்னும் கொஞ்சம் நல்லா பண்ணி இருக்கலாம். முக்கியமா, "காக்க காக்க" சாயல் இல்லாம பண்ணி இருக்கலாம். அப்புறம், மொத ரேங்க் வாங்கற டாக்டர் "சாகா வரம்" பத்தி பேசறது எல்லாம் லாஜிக்கே இல்லாத விசயம்.

வன்முறை: கொஞ்சம் ஓவருங்க. கழுத்த அறுத்தா ரத்தம் கொப்புளிச்சி வரும் தான். அத அப்படியே படத்துல காட்டணுமா?

இங்கிலீஸு: நியூயார்க்ல நடக்கற விசாரணை பூரா இங்கிலீஷ் வசனம் - தமிழ் சப்-டைடில். B, C  சென்டர்ல படம் பார்க்கறவங்களுக்காக அஞ்சு நிமிசத்துக்கு ஒரு தடவ கமல் இந்தியாக்கு போன்ல update பண்ணற மாதிரி தமிழ்ல கதை சொல்லறார். எடுபடுமான்னு தெரியல.

படம் பார்த்துட்டு வெளிய வந்த ரெண்டு பேர் பேச கேட்டது:

"கமல் இண்டியன் சினிமாவோட சிங்கம்டா. சும்மா சொல்லக்கூடாது படம் சுப்பர் இல்ல?"

"ஆமா மச்சி. அடுத்ததா உங்க தலைவரு காமெடி படம் தான எடுப்பாரு?"

Posted in Labels: | 0 comments

தமிழ் இனி மெல்லச் சாகும்…

பெங்களூர் வலைப்பதிவர்கள் சந்திப்பு பத்தி இங்க எழுதி இருந்தேன். அதுல "என்னால ரொம்ப எல்லாம் தமிழ் பேச முடியாது" -ன்னு அறிமுகப்படுத்திகிட்ட பாரதியோட blog பக்கம் எட்டி பார்த்தேன். ஒரு நிமிசம் ஹார்ட் அட்டாக் வந்திடுச்சு. அசத்தலான குறள் வெண்பா எழுதி வெச்சிருக்காங்க. ரெண்டு சாம்பிள்:

கதவுதிறந் தோடிவந் தென்மழலை சொல்லும்
மொழியின் இனிதோ தமிழ்?


சோர்வாய் படித்து முடித்து உறங்கிடப்
போவோம் விடியும் பொழுது


இதைப்படிச்சதுக்கு அப்புறம் தலைப்புக்கும் இதுக்கும் என்ன சம்மந்தம்னு கேக்கறீங்களா? தமிழுக்கு வந்த போதாத காலம், எனக்கும் குறள் வெண்பா எழுத ஆசை வந்திருச்சு. பாரதி போன ஜென்மத்துல நிறைய புண்ணியம் செஞ்சு இருக்காங்க. இல்லைன்னா என்ன மாதிரி சிஷ்யன் கிடைப்பாங்களா? ;-) கொஞ்சம் பொறுமையா பகுபத உறுப்பிலக்கணத்துல ஆரம்பிச்சு வெண்பா ரூல்ஸ் எல்லாம் சொல்லி கொடுத்தாங்க. நானும் ஏதோ கத்துகிட்டு தமிழை கொலை பண்ணப்போறேன். தமிழ் மேல அதீத பற்று இருக்கறவங்க தயவு செஞ்சு இதோட இந்த blog படிக்கறத நிறுத்திடுங்க. இதோ என்னோட மொத குறள்:

பதிவு எழுதியது போதாதென் றெண்ணி
எழுத நினைத்தேன் குறள்.

Posted in Labels: | 2 comments

இம்சை அரசன் 23ம் புலிகேசி

ரெண்டு வாரத்துக்கு முன்னாடி சன் டீவி டாப் டென்ல இந்த படம் மொதல்ல வந்ததா நியாபகம். சரி நல்ல படம் போலன்னு சீடி எடுத்துட்டு வந்துட்டேன். குழந்தைகளுக்கு பிடிச்ச காரணத்துக்காகவும், குடும்பத்தோட பார்க்கக்கூடிய காரணத்துக்காகவும் தான் தியேட்டர்ல கூட்டம் வரதா பசங்க சொன்னாங்க. ஒண்ணு, ரெண்டு தவிர மத்தது எல்லாமே கொஞ்சம் கடியான காமெடி தான்.

"ஒன்பதுஎழுத்த்து" டைட்டில், ஏழை ஹீரோ, டமில் பேசற பணக்கார ஹீரோயின், மரத்த சுத்தி ஒரு ரெயின் சாங், அம்மா தாலி வெச்சு ஒரு சுப்பர் சென்டிமெண்ட், தொப்புள்ள பனியாரம் சுடுற சீன், ஓடுற ட்ரெயின் மேல கிளைமாக்ஸ் பைட், இத்யாதி, இத்யாதி - இந்த மாதிரி ஒரு "வெற்றிப்படத்துக்கு" அத்தியாவிசயமான சமாச்சாரம் எதுவும் இல்லாம, சுத்தமான தமிழ்ல ஒரு ராஜா காலத்து காமெடி கதை எடுக்கலாம்ன்னு யோசிச்ச டைரக்டர் சிம்புவிற்கு ஒரு பெரிய சபாஷ்.

இந்த மாதிரி ஒரு படத்துக்கு, அதுவும் ஒரு அறிமுக டைரக்டர நம்பி பணம் போட்டிருக்குற சங்கருக்கு இன்னொரு பெரிய சபாஷ். (அது ஏன் சார் உங்க படத்துக்கு மட்டும் வேற தயாரிப்பாளர் கிட்ட போறீங்க?)

அடுத்த சபாஷ், படத்தோட ஹீரோ (!) வடிவேலுவுக்கு. முந்தி எல்லாம் வடிவேலு காமெடின்னாலே செனல் மாத்திடுவேன். வீர வசனம் பேசிட்டு கோவை சரளாவை கூட்டிட்டு போயி கதவ சாத்தும் போதே தெரிஞ்சு போயிடும், நம்ம வீட்டு கத தான் நடக்க போகுதுன்னு. அத டீவீல வேற பார்க்கனுமான்னு, யோசிக்காம செனல் மாத்திடுவேன். அப்புறம், வின்னர் படம் வந்து தான் அவருக்கு ஒரு பிரேக் தந்துச்சு. சும்மா சொல்லக்கூடாது, டீவீல விடுங்க, அந்த சீன நெனச்சு பார்த்தாலே சிரிச்சுடுவேன். அப்படி ஒரு காமெடியன், படம் முழுக்க ஒரு சீரியஸ் ரோல்ல நடிச்சு பேர் வாங்கறது கொஞ்சம் கஷ்டம். அதை ஒரு அளவுக்காவது பண்ணியிருக்கார். அவருக்கு ஒரு சபாஷ்.

வழக்கம் போல தன்னோட கதாபாத்திரத்தை உணர்ந்து நடித்திருக்கும் நாசருக்கு இன்னோரு சபாஷ்.

கொஞ்சம் நாடகத்தனம், கொஞ்சம் கடி பாடல்கள், கொஞ்சம் வெறுப்பேத்தும் காமெடி, இதை எல்லாம் தள்ளி வெச்சுட்டு பார்த்தால், மொத்தத்துல ஒரு நல்ல டைம் பாஸ்.

Posted in Labels: | 0 comments

Windows Live Writer !

M$ has released a nice tool called Windows Live Writer. Its a WYSIWYG editor for blogs. You can download it here. I'm writing this entry from the editor. Let me see how it comes.

<test>

RED is smaller than BLUE.

Verdana, Times New Roman, Arial, Tahoma,

தமிழிலும் தட்டச்சு செய்யலாம்!

</test>

Posted in Labels: | 0 comments

Bye Bye Blogspot, Hello WordPress!

With BlogSpot there is no way to tag my blog entries. When you get a comment in your mail, there is no way to know from which entry the comment was for. There were few hiccups like this. I decided to move to WordPress for a long time, and as usual I can blame on my laziness for not doing it. Finally I did it now. The transition was smooth. There is an import option in WordPress, where you can give you blogger id and password. It will give you the list of blogs you have. Click on the ones you want to import and its done!

One big disadvantage I'm seeing here with WordPress is that you can't actually create/tweak the templates. You have to select the available ones and use it. But thats OK. The template I've chosen is not that bad. I can live with this. I'm still correcting the images, and few other things. Please let me know if anything is missing here.

Posted in Labels: | 0 comments

One more year!!!

One more year has gone and I turn back and see the events.

First on my personal side. I've shifted from Chennai to Bangalore. I'm no more single and to add more to that I'm an expectant father.

From my official side, I've put down my papers and shifted company. If that is not enough, I've again put down my papers last week and expected to move to my third company sometime next month. On the other hand, I've released an open source product and its going well. I discovered a tutorial for it in Japanese!

Wow! There are too many changes and all for good! It might be the most exciting year I've ever had in my life so far. But no matter what, I'm still 18 years old. This year again failed to increase my age. To quote Bryan Adams again:

Don’t worry about the future - forget about the past
gonna have a ball - ya we’re gonna have a blast
gonna make it last
18 till I die

Posted in Labels: | 0 comments

This blog has moved to wordpress

I've moved this blog to wordpress. Please change your bookmarks to here

Posted in | 0 comments

புதுப்பேட்டை: ஒரு நாளில் வாழ்க்கை

ஒரு நாளில் வாழ்க்கை இங்கே எங்கும் ஓடி போகாது
மறு நாளும் வந்து விட்டால் துன்பம் தேயும் தொடராது
எத்த்னை கோடி கண்ணீர் மண் மீது விழுந்திருக்கும்
அத்தனை கண்ட பின்னும் பூமி இங்கு பூ பூக்கும்
ஓஓஓஓஓஓ, கரு வாசல் தொட்டு வந்த நாள் தொட்டு
ஓஓஓஓஓஓ, ஒரு வாசல் தேடியே விளையாட்டு
ஓஓஓஓஓஓ, கண் திறந்து பார்த்தால் பல கூத்து
ஓஓஓஓஓஓ, கண் மூடிக்கொண்டால்
ஓஓஓஓஓஓ ...

போர்களத்தில் பிறந்துவிட்டோம், வந்தவை போனவை வருத்தமில்லை
காட்டினிலே வாழ்கின்றோம், முட்களின் வலி ஒன்றும் மரணமில்லை
இருட்டினிலே நீ நடக்கயிலே உன் நிழலும் உன்னை விட்டு விலகிவிடும்
நீ மட்டும் தான் இந்த உலகத்திலே உனக்கு துணை என்று விளங்கிவிடும்
தீயோடு போகும் வரையில், தீராது இந்த தனிமை
கரை வரும் நேரம் பார்த்து,கப்பலில் காத்திருப்போம்
எரிமலை வந்தால் கூட ஏறி நின்று போர் தொடுப்போம்
ஓஓஓஓஓஓ, அந்த தெய்வ ரகசியம் புரிகிறதே
ஓஓஓஓஓஓ, இங்கு எதுவும் நிலையில்லை கரைகிறதே
ஓஓஓஓஓஓ, மனம் வெட்ட வெளியிலே அலைகிறதே
ஓஓஓஓஓஓ, அந்த கடவுளை கண்டால்
ஓஓஓஓஓஓ ...

அது எனக்கு இது உனக்கு இதயங்கள் போடும் தனிக்கணக்கு
அவள் எனக்கு இவள் உனக்கு உடல்களும் போடும் புதிர்க்கணக்கு
உனக்குமில்லை இது எனக்குமில்லை, படைத்தவனே இங்கு எடுத்துக்கொள்வான்
நல்லவன் யார், அட கெட்டவன் யார், கடைசியில் அவனே முடிவு செய்வான்
பழி போடும் உலகம் இங்கே,பலியான உயிர்கள் எங்கே
உலகத்தின் ஓரம் நின்று அத்தனையும் பார்த்திருப்போம்
நடப்பவை
நாடகம் என்று நாமும் சேர்ந்து நடித்திருப்போம்
ஓஓஓஓஓஓ, பல முகங்கள் வேண்டும் சரி மாட்டிக்கொள்வோம்,
ஓஓஓஓஓஓ, பல திருப்பம் தெரியும் அதில் திரும்பிக்கொள்வோம்,
ஓஓஓஓஓஓ, கதை முடியும் போக்கில் அதை முடித்துக்கொள்வோம்,
ஓஓஓஓஓஓ, மறு பிறவி வேண்டுமா
ஓஓஓஓஓஓ ...

INSAT 4C launch unsuccessful :-(

Who will get affected by this? In my opinion:

(*) People invested in DTH. This Insat was supposed to boost the transmission of DTH. Now we have to depend on your local cable operators/SCV/Hathway
(*) People who bought trasnponders. They have to switch to Plan B
(*) ISRO. Their plans to commercialize the satellite launching will get affected by this
(*) Met dept. Insat was also meant for meterological imaging.

Good thing that GSLV is not the carrying vehicle for India's mission to the moon:Chandrayan. PSLVs will be used.

Posted in | 0 comments