I didn't find how to install GWT into eclipse. Finally I find a possible approach which i docmented as follows. May b its helpful, if not , feel free to get in touch with me.In this example i would create an application which finally makes an async call to server and fetches the time from there.
To the end we should be able to debug inline with eclipse editor. Here i use my-eclipse i think it works even with eclipse editor also. Its a simple applicatoin.
By the way, whats GWT? and documentation etc, i leave it to the home site of gwt.
now by project creator,
create a web project, uncheck the default location, as below, and locate the sourece folder.
u should see the following in the navigator of eclipse
now the scene starts, when u run the gwt, in standalone mode, it creates www, bin folders and does the processings, but now need to make it create WebRoot and WebRoot/classes and use them instead. This requires editing of cmd files and here we go!
open compile cmd file as follows
@java -cp "%~dp0\src;%~dp0\bin;D:/r/work/UI/gwt-windows-1.3.3/gwt-user.jar;D:/r/work/UI/gwt-windows-1.3.3/gwt-dev-windows.jar" com.google.gwt.dev.GWTCompiler -out "%~dp0\www" %* com.ui.clock
is what u see, now change
bin -> WebRoot\WEB-INF\classes
www -> WebRoot
To check if rpc is also working proceesd as follows:
create a new class as ClockInt.java
create the following interface
package com.ui.client;
public interface ClockInt extends RemoteService{
String getDate();
}
create the async interface as follows
package com.ui.client;
public interface ClockIntAsync {
}
The IDE may throw errors, for it u need to import the 3 jar files in gwt.xip that you have downloaded from the GWT home page and include them in eclipse properties (how? right click on project select properties, click on java build path, click on libraries tab, add external jars, and navigate to the gwt-windows 1.3.3 -could be found when u unzip the gwt-windows 1.3.3 zip file from gwt home page. Select all the three jar files.)
The errors now disappear, if still not refresh the project.
Create the server side implimentation to the ClockInt as follows:
1. create the folder server at ui.com this results in com.ui.server package.
write the folloing code in the package
package com.ui.server;
import java.util.Date;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.ui.client.ClockInt;
public class ClassImpl extends RemoteServiceServlet implements ClockInt {
public String getDate() {
Date today = new Date();
return today.toLocaleString();
}
}
update the clock.gwt.xml file as follows
<module>
<inherits name='com.google.gwt.user.User'/>
<entry-point class='com.ui.client.clock'/>
<servlet path="/Clock.rpc" class="com.ui.server.ClockImpl" />
module>
public class clock implements EntryPoint {
public void onModuleLoad() {
final Button button = new Button("Click me again");
final Label label = new Label();
ClockIntAsync clockAsync = (ClockIntAsync) GWT.create(ClockInt.class);
ServiceDefTarget endPoint = (ServiceDefTarget) clockAsync;
endPoint.setServiceEntryPoint("./Clock.rpc");
AsyncCallback asyncCallBack = new AsyncCallback() {
public void onSuccess(Object result) {
RootPanel.get().add(new HTML(result.toString()));
}
public void onFailure(Throwable ex) {
RootPanel.get().add(new HTML(ex.toString()));
}
};
clockAsync.getDate(asyncCallBack);
button.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
if (label.getText().equals(""))
label.setText("Hello World!");
else
label.setText("");
}
});
RootPanel.get("slot1").add(button);
RootPanel.get("slot2").add(label);
}
}
Test the configuration in stand alone mode. Click on clock-compile.bat and then on clock-shell.bat successively. You should see the clock displayd to the bottom of page.
To deploy to webservr:
Make these entries:
<servlet>
<servlet-name>clockRPCservlet-name>
<servlet-class>com.ui.server.ClockImplservlet-class>
servlet>
<servlet-mapping>
<servlet-name>clockRPCservlet-name>
<url-pattern>/com.ui.clock/Clock.rpcurl-pattern>
Things are ready and deolpy the project onto tomcat server as exploed archive. Start the server, and try with this url:
URL: http://localhost:8080/Clock/com.ui.clock/clock.html
u should see the same clock as u saw in stand alone mode. Thats it.
references: http://www.oracle.com/technology/pub/articles/dubois-gwt.html?msgid=5128898
http://roberthanson.blogspot.com/2006/06/trivial-gwt-example.html