XqSun
unread,Oct 28, 2009, 8:46:23 AM10/28/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google Web Toolkit Applications
Hi Ryan,
Thank you for your excellent book.
I have a problem when developing a new program, based on your example
of Chapter 9.
My program is very simple, client side sends a RPC request to server
to get a string to display a count number. Server delays 1 second
before sending back the count string. Thus the web screen displays a
count number increasing each second.
The program works well with hosted browser and IE. However, when I
test it on Chrome I see problems as following:
- Chrome always displays waiting mouse pointer (glass hour) and
loading icon on the tab. However the counter still works correctly
- If I press Escape keyboard button, Chrome stops that loading status
but the counter stops working too.
I have tried your example but did not see that problem.
Can you help me to find what I missed?
Thank you a lot in advance.
The code is bellow (I am using Eclipse):
-------------------------------------------
File TestMsg .java
package com.mysite.testmsg.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
public class TestMsg implements EntryPoint {
private final MyServiceAsync eventService = GWT.create
(MyService.class);
Label label = new Label("Count: 0");
private class GetEventsCallback implements AsyncCallback{
public void onFailure(Throwable throwable){ GWT.log("Client
GetEventsCallback: error get events", throwable); }
public void onSuccess(Object obj){
String str = (String)obj;
label.setText(str);
eventService.getEvent( this );
}
}
public void onModuleLoad() {
RootPanel.get().add(label);
eventService.getEvent( new GetEventsCallback() );
}
}
-------------------------------------------
File MyService .java
package com.mysite.testmsg.client;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("myservice")
public interface MyService extends RemoteService {
String getEvent();
}
-------------------------------------------
File MyServiceAsync.java
package com.mysite.testmsg.client;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface MyServiceAsync {
void getEvent(AsyncCallback<String> callback);
}
-------------------------------------------
File MyServiceImpl .java
package com.mysite.testmsg.server;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.mysite.testmsg.client.MyService;
@SuppressWarnings("serial")
public class MyServiceImpl extends RemoteServiceServlet implements
MyService {
static int count = 0;
public String getEvent() {
count++;
try{
synchronized( this ){
this.wait( 1*1000 );
}
}
catch (InterruptedException ignored){}
return "Count: "+count;
}
}
-------------------------------------------
File web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<servlet>
<servlet-name>myServlet</servlet-name>
<servlet-class>com.mysite.testmsg.server.MyServiceImpl</servlet-
class>
</servlet>
<servlet-mapping>
<servlet-name>myServlet</servlet-name>
<url-pattern>/testmsg/myservice</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>TestMsg.html</welcome-file>
</welcome-file-list>
</web-app>
-------------------------------------------
File TestMsg.gwt.xml
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='testmsg'>
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<entry-point class='com.mysite.testmsg.client.TestMsg'/>
</module>