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.likesincommon.client.LoginFb.java

License:Apache License

public void getMyInfo() {

    String url = JSON_URL;

    url += "/me?access_token=" + tokenFb;

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

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

From source file:com.lushprojects.circuitjs1.client.ExportAsUrlDialog.java

License:Open Source License

public ExportAsUrlDialog(String dump) {
    super();/* w w w. j a v  a 2s.c o m*/
    String start[] = Location.getHref().split("\\?");
    dump = dump.replace(' ', '+');
    String query = "?cct=" + URL.encode(dump);
    dump = start[0] + query;
    requrl = URL.encodeQueryString(query);
    Button okButton;

    Label la1, la2;
    vp = new VerticalPanel();
    setWidget(vp);
    setText(CirSim.LS("Export as URL"));
    vp.add(new Label(CirSim.LS("URL for this circuit is...")));
    if (dump.length() > 2000) {
        vp.add(la1 = new Label(
                CirSim.LS(
                        "Warning: this URL is longer than 2000 characters and may not work in some browsers."),
                true));
        la1.setWidth("300px");
    }
    vp.add(tb = new RichTextArea());
    tb.setText(dump);
    //      tb.setMaxLength(s.length());
    //      tb.setVisibleLength(s.length());
    vp.add(la2 = new Label(CirSim.LS(
            "To save this URL select it all (eg click in text and type control-A) and copy to your clipboard (eg control-C) before pasting to a suitable place."),
            true));
    la2.setWidth("300px");

    HorizontalPanel hp = new HorizontalPanel();
    hp.setWidth("100%");
    hp.setStyleName("topSpace");
    hp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    hp.add(okButton = new Button(CirSim.LS("OK")));
    vp.add(hp);
    if (shortIsSupported()) {
        hp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);

        hp.add(shortButton = new Button(CirSim.LS("Create short URL")));
        shortButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                shortButton.setVisible(false);
                createShort(requrl);
            }
        });
    }
    okButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            closeDialog();
        }
    });
    this.center();
}

From source file:com.mallentechinc.smartwire.client.SmartWireWeb.java

License:Open Source License

protected void getAllUsers() {
    String url = USER_JSON_URL + "getAllUsers.do?";
    url = URL.encode(url);
    // Send request to server and catch any errors.
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);

    try {// www.j a  v  a  2 s.  c o m
        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(asArrayOfStockData(response.getText()));
                } else {
                    displayError("Couldn't retrieve JSON (" + response.getStatusText() + ")");
                }
            }
        });
    } catch (RequestException e) {
        displayError("Couldn't retrieve JSON");
    }

}

From source file:com.mallentechinc.smartwire.client.SmartWireWeb.java

License:Open Source License

protected void logoff() {
    String url = BASE_URL + "j_spring_security_logout";
    url = URL.encode(url);
    // Send request to server and catch any errors.
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);

    try {//from  www. j  a  v a2s . c o  m
        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()) {
                    redirect(BASE_URL + "spring_security_login");
                } else {
                    displayError("Couldn't retrieve JSON (" + response.getStatusText() + ")");
                }
            }
        });
    } catch (RequestException e) {
        displayError("Couldn't retrieve JSON");
    }

}

From source file:com.mallentechinc.smartwire.client.SmartWireWeb.java

License:Open Source License

protected void getAllCircuitsByUser(String userName) {
    String url = SUBSYSTEM_JSON_URL + "getAllCircuitsByUser.do?";
    url = URL.encode(url);
    // Send request to server and catch any errors.
    RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, url);

    try {/* ww w  . java 2 s .  c  om*/
        builder.setHeader("Content-Type", "application/json");

        String requestDate = "{\"userName\":\"jxu\"}";

        Request request = builder.sendRequest(requestDate, 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()) {
                    updateUserCircuitTable(asArrayOfCircuitData(response.getText()));

                } else {
                    displayError("Couldn't retrieve JSON (" + response.getStatusText() + ")");
                }
            }
        });
    } catch (RequestException e) {
        displayError("Couldn't retrieve JSON");
    }

}

From source file:com.mallentechinc.smartwire.client.SmartWireWeb.java

License:Open Source License

protected void getLoginUserName() {
    String url = USER_JSON_URL + "getLoginUser.do?";
    url = URL.encode(url);
    // Send request to server and catch any errors.
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);

    try {/*www . java 2  s .  c  o  m*/
        Request request = builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {

            }

            public void onResponseReceived(Request request, Response response) {
                if (200 == response.getStatusCode()) {
                    loginUserName = response.getText();
                    nlnhtmlUsername = new InlineHTML(response.getText());

                }
            }
        });
    } catch (RequestException e) {
        //do nothing
    }

}

From source file:com.mallentechinc.smartwire.client.SmartWireWeb.java

License:Open Source License

protected void saveUpdateUser(String requestData) {
    String url = USER_JSON_URL + "saveUpdateUser.do?";
    url = URL.encode(url);
    // Send request to server and catch any errors.
    RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, url);

    try {/*from   ww  w.ja  v a  2s. com*/
        builder.setHeader("Content-Type", "application/json");

        System.out.println("RequestData-->" + requestData);
        Request request = builder.sendRequest(requestData, 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()) {
                    //reset
                    firstName.setText("");
                    lastName.setText("");
                    email.setText("");
                    passWord.setText("");
                    userName.setText("");

                    getAllUsers();
                    deckPanel.showWidget(1);
                } else {
                    displayError("Couldn't retrieve JSON (" + response.getStatusText() + ")");
                }
            }
        });
    } catch (RequestException e) {
        e.printStackTrace();
        displayError("Couldn't retrieve JSON");
    }

}

From source file:com.mallentechinc.smartwire.client.SmartWireWeb.java

License:Open Source License

protected void deleteUser(String requestData) {
    String url = USER_JSON_URL + "deleteUser.do?";
    url = URL.encode(url);
    // Send request to server and catch any errors.
    RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, url);

    try {//w  w w.  j a va  2  s  .com
        builder.setHeader("Content-Type", "application/json");

        System.out.println("RequestData-->" + requestData);
        Request request = builder.sendRequest(requestData, 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()) {
                    getAllUsers();
                    deckPanel.showWidget(1);
                } else {
                    displayError("Couldn't retrieve JSON (" + response.getStatusText() + ")");
                }
            }
        });
    } catch (RequestException e) {
        e.printStackTrace();
        displayError("Couldn't retrieve JSON");
    }

}

From source file:com.preferanser.client.application.mvp.unauthorized.UnauthorizedPresenter.java

License:Open Source License

@Override
protected void onReveal() {
    String returnUrl = URL.encode(Window.Location.getHref());
    String loginUrl = user.getLoginUrl().replace("%2F", returnUrl);
    Window.Location.assign(loginUrl);
}

From source file:com.qtitools.player.client.util.xml.XMLDocument.java

License:Open Source License

/**
 * Create assessment from xml// w  w  w  . j  ava  2 s  .  c  om
 */
public XMLDocument(String url, IDocumentLoaded l) {

    listener = l;
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));
    baseUrl = url.substring(0, url.lastIndexOf("/") + 1);

    errorString = null;
    try {
        builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                // Couldn't connect to server (could be timeout, SOP violation, etc.)    
                errorString = "Error" + exception.toString();
            }

            public void onResponseReceived(Request request, Response response) {
                // StatusCode == 0 when loading from local file
                try {
                    if (response.getStatusCode() == 200 || response.getStatusCode() == 0) {

                        dom = XMLParser.parse(response.getText());
                        listener.finishedLoading(dom, baseUrl);

                    } else {
                        // Handle the error.  Can get the status text from response.getStatusText()
                        errorString = "Wrong status: " + response.getText();
                        listener.loadingErrorHandler(errorString);
                    }
                } catch (Exception e) {
                    listener.loadingErrorHandler(e.getMessage());
                }
            }
        });

    } catch (RequestException e) {
        // Couldn't connect to server    
        errorString = "Can't connect to the server: " + e.toString();
    } catch (DOMException e) {
        errorString = "Could not parse file: " + url;
    }

    if (errorString != null)
        listener.loadingErrorHandler(errorString);

}