String longUrl = Window.prompt("Enter a long URL",
"http://gwt-google-apis.googlecode.com/svn/trunk/apis/samples/urlshortener/demo/"
+ "urlshortener.html");
// Get a new RequestContext which we will execute.
UrlContext urlContext = urlShortener.url();
// Create a new Url instance with the longUrl we want to insert.
Url url = urlContext.create(Url.class).setLongUrl(longUrl);
// Fire an insert() request with the Url to insert.
urlContext.insert(url).fire(new Receiver<Url>() {
@Override
public void onSuccess(Url response) {
Window.alert("Long URL: " + response.getLongUrl() + "\n" //
+ "Short URL: " + response.getId() + "\n" //
+ "Status: " + response.getStatus());