Tuesday, February 3, 2009

Using 3rd Party non-GWT jars in GWT project

Hello guys. 

Today I want to share my experience how I able to use 3rd-party non-GWT jar insie my GWT application. These 3rd-party jar can be apache-commons-* or any other project  developed by other team memebers.

Now I will explain step by step way how we can easily use external jar file wish GWT. The only thing which should be taken into consideration is that the project jar we are using has all source should be translateble to the GWT and vice versa.

Now we proceed step by step.

Step 1) lets we had created one project "com.eaglecoder.ejb" which contain the domain object i.e            POJO which will be used to set /get data in our GWT project. 
    - We will create XXX.gwt.xml file at the root of that project i.e. TestingUserDomain.gwt.xml"

the TestingUserDomain.gwt.xml file should contain the "source" entry which will define the path of the pojo.


TestingUserDomain.gwt.xm

       <module>
   
<inherits name='com.google.gwt.user.User'/>
  <source path="com.eaglecoders.erp.ejb.domain"/>
 
  </module>

Step 2) we will export this project to "jar" file i.e. com.eaglecoders.ejb.jar.

Step 3) we create GWT project and add this jar file into its BuildPath and also in its classpath to compile the GWT source. i.e. "MainApp-shell.cmd" and "MainApp-compile.cmd". 

Step 4) Add the following line in your MainApp.gwt.xml file to use the ejb project created in
 step 1 - step 3

    <inherits name = 'TestingUserDomain'/>


this name is always the first section of the gwt.xml file name. i.e. TestingUserDomain.gwt.xml.

hopefully this will help you all guys how easily you can use your external jar file with GWT project.

Cheers