Share Coding

Tutorials, Problems, Stuffs …

Category Archives: GWT

The most clear and easy understanding Comet(Server-push) Tutorial

Nucular... It's pronounced Nucular

Yesterday I’ve discovered GWTEventService. Today i started to play around with it, after some research in the example-svn and reading the docs, I was able to write my own “Hello World”.

This Hello World is a small chatting application. You are only able to send messages but not set a nickname or something similar.

Here you can see what it will look like:gwteventservice-helloworld1

In this short overview I’ll just show you the parts that are associated with the GWTEventSerice. The whole regular GWT UI/RPC stuff is left out. If you want to see the complete example, you can download it here.

First of all you need an Event:

This Event gets fired when the server gets a new message from a client.

The next thing you need is a EventListener that gets notified when an Event occures:

The Listener receives the Events from the server an processes…

View original post 67 more words

Cross Domain Request on GWT without RPC

Since RequestBuilder do not support cross domain on GWT, the other option will be JsonpRequestBuilder
Here is an example between client and server (PHP).

 
Client.java

JsonpRequestBuilder jsonp = new JsonpRequestBuilder();
jsonp.requestObject(URL.encode("http://serverurl/Server.php?callback=test_clbk"), new AsyncCallback() {
	public void onFailure(Throwable throwable) {
		System.out.println(throwable.getMessage());
	}
	public void onSuccess(JSONreceiver result) {
		System.out.println(result.getResult());
	}
});

 
Read more of this post

Recognize Devices on GWT

static final String[] MOBILE_SPECIFIC_SUBSTRING = {
	"iPhone","Android","MIDP","Opera Mobi",
	"Opera Mini","BlackBerry","HP iPAQ","IEMobile",
	"MSIEMobile","Windows Phone","HTC","LG",
	"MOT","Nokia","Symbian","Fennec",
	"Maemo","Tear","Midori","armv",
	"Windows CE","WindowsCE","Smartphone","240x320",
	"176x220","320x320","160x160","webOS",
	"Palm","Sagem","Samsung","SGH",
	" SIE","SonyEricsson","MMP","UCWEB"
};

 

private boolean checkMobile() {
	String userAgent = Window.Navigator.getUserAgent();
	for (String mobile: MOBILE_SPECIFIC_SUBSTRING){
		if (userAgent.contains(mobile)
			|| userAgent.contains(mobile.toUpperCase())
			|| userAgent.contains(mobile.toLowerCase())){
			return true;
		}
	}
	return false;
}