Example usage for com.google.gwt.http.client URL encode

List of usage examples for com.google.gwt.http.client URL encode

Introduction

In this page you can find the example usage for com.google.gwt.http.client URL encode.

Prototype

public static String encode(String decodedURL) 

Source Link

Document

Returns a string where all characters that are not valid for a complete URL have been escaped.

Usage

From source file:com.google.gwt.sample.stockwatcher_json.client.StockWatcherJSON.java

private void refreshWatchList() {
    if (stocks.size() == 0) {
        return;/* w  ww. j a v  a2  s  . c  om*/
    }

    String url = JSON_STOCK_PRICES_URL;

    // Append watch list stock symbols to query URL.
    Iterator<String> iter = stocks.iterator();
    while (iter.hasNext()) {
        url += iter.next();
        if (iter.hasNext()) {
            url += "+";
        }
    }

    url = URL.encode(url);
    GWT.log("url = " + url);
    // Send request to server and catch any errors.
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);

    try {
        builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                displayError("Couldn't retrieve JSON : " + exception.getMessage());
            }

            public void onResponseReceived(Request request, Response response) {
                if (200 == response.getStatusCode()) {
                    updateTable(asArrayOfStockData(response.getText()));
                } else {
                    displayError("Couldn't retrieve JSON (" + response.getStatusText() + ")");
                }
            }
        });
    } catch (RequestException e) {
        displayError("Couldn't retrieve JSON : " + e.getMessage());
    }
}

From source file:com.google.gwt.sample.userwatcher.client.PageWithoutPhoto.java

private void refreshWatchList() {

    if (stocks.size() == 0) {
        return;//from  w w w  . ja v a2 s . c  o m
    }

    String url = JSON_URL;

    // Append watch list stock symbols to query URL.
    Iterator<String> iter = stocks.iterator();
    while (iter.hasNext()) {
        url += iter.next();
        if (iter.hasNext()) {
            url += "+";
        }
    }

    url = URL.encode(url);

    // Send request to server and catch any errors.
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);

    try {
        Request request = builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                displayError("Couldn't retrieve JSON");
            }

            public void onResponseReceived(Request request, Response response) {
                if (200 == response.getStatusCode()) {
                    updateTable(JsonUtils.<JsArray<StockData>>safeEval(response.getText()));
                } else {
                    displayError("Couldn't retrieve JSON (" + response.getStatusText() + ")");
                }
            }
        });
    } catch (RequestException e) {
        displayError("Couldn't retrieve JSON");
    }

}

From source file:com.google.lotrepls.client.CommandPrompt.java

License:Apache License

private static String buildUrl(InterpreterType t, String script) {
    return Location.getHref() + "?language=" + t.name() + "&script=" + URL.encode(script);
}

From source file:com.google.mobile.trippy.web.client.base.DefaultUtils.java

License:Apache License

@Override
public String getLoginUrl(String destination) {
    final String loginUrl = nativeGetLoginUrl();
    if (loginUrl == null) {
        return null;
    }/*from  w  ww.j  a  v a2 s  . com*/
    return loginUrl.replace(UserUtils.AUTH_DESTINATION_URL_DUMMY, URL.encode(destination));
}

From source file:com.google.mobile.trippy.web.client.base.DefaultUtils.java

License:Apache License

@Override
public String getLogoutUrl(String destination) {
    final String logoutUrl = nativeGetLogoutUrl();
    if (logoutUrl == null) {
        return null;
    }//from   w w  w.j  av a  2s .  c  o  m
    return logoutUrl.replace(UserUtils.AUTH_DESTINATION_URL_DUMMY, URL.encode(destination));
}

From source file:com.googlesource.gerrit.plugins.xdocs.client.PatchSetSelectBox.java

License:Apache License

private Anchor createDownloadLink() {
    String base = GWT.getHostPageBaseURL() + "cat/";
    String sideUrl = isBaseSelected() ? "1" : "0";
    int ps = isBaseSelected() ? change.revision(change.current_revision())._number() : getSelectedPatchSet();
    Anchor anchor = new Anchor(new ImageResourceRenderer().render(XDocsPlugin.RESOURCES.downloadIcon()),
            base + URL.encode(change._number() + "," + ps + "," + path) + "^" + sideUrl);
    anchor.setTitle("Download");
    return anchor;
}

From source file:com.googlesource.gerrit.plugins.xdocs.client.XDocsPlugin.java

License:Apache License

public static String getSideBySideDiffUrl(String changeId, Integer patchSetIdA, int patchSetIdB,
        String fileName) {//  ww  w. j a  va2s  . co  m
    StringBuilder url = new StringBuilder();
    url.append("/c/");
    url.append(changeId);
    url.append("/");
    if (patchSetIdA != null) {
        url.append(patchSetIdA);
        url.append("..");
    }
    url.append(patchSetIdB);
    url.append("/");
    url.append(URL.encode(fileName));
    return url.toString();
}

From source file:com.likesincommon.client.LoginFb.java

License:Apache License

public void getMyLikes() {
    //disableButton();
    String url = JSON_URL;

    //get my likes
    url += "me/likes?access_token=" + tokenFb;

    // Append the name of the callback function to the JSON URL.
    url = URL.encode(url) + "&callback=";

    String callbackName = reserveCallback();
    setupMyLikes(this, callbackName);
    addScript(callbackName, url + callbackName);
}

From source file:com.likesincommon.client.LoginFb.java

License:Apache License

public void getMyFriends() {

    String url = JSON_URL;

    //get my likes
    url += "me/friends?access_token=" + tokenFb;

    // Append the name of the callback function to the JSON URL.
    url = URL.encode(url) + "&callback=";

    String callbackName = reserveCallback();
    setupMyFriends(this, callbackName);
    addScript(callbackName, url + callbackName);
}

From source file:com.likesincommon.client.LoginFb.java

License:Apache License

public void getLikesInCommon(Friend f) {

    String url = JSON_URL;

    //Friend f1 = friends.get(3);
    //Friend f2 = friends.get(5);
    //friends = new ArrayList<Friend>();
    //friends.add(f1);
    //friends.add(f2);
    //for (Friend f : friends){
    String id = f.getId();//www.ja  va  2  s .c o m

    url += id + "/likes?access_token=" + tokenFb;

    // Append the name of the callback function to the JSON URL.
    url = URL.encode(url) + "&callback=";

    String callbackName = reserveCallback();
    setupLikesInCommon(this, callbackName, id);
    addScript(callbackName, url + callbackName);
    //}
    //enableButton();
}