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

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

Introduction

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

Prototype

public static String encodeQueryString(String decodedURLComponent) 

Source Link

Document

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

Usage

From source file:com.arcbees.analytics.client.ClientAnalytics.java

License:Apache License

public void fallback(JsArrayMixed arguments) {
    if ("send".equals(arguments.getString(0))) {
        JSONObject jsonOptions = new JSONObject(arguments.getObject(arguments.length() - 1));
        StringBuilder url = new StringBuilder();
        url.append(fallbackPath).append("?");
        url.append(ProtocolTranslator.getFieldName("hitType")).append("=")
                .append(URL.encodeQueryString(arguments.getString(1)));

        for (String key : jsonOptions.keySet()) {
            if (!"hitCallback".equals(key)) {
                JSONValue jsonValue = jsonOptions.get(key);
                String strValue = "";
                if (jsonValue.isBoolean() != null) {
                    strValue = jsonValue.isBoolean().booleanValue() + "";
                } else if (jsonValue.isNumber() != null) {
                    strValue = jsonValue.isNumber().doubleValue() + "";
                } else if (jsonValue.isString() != null) {
                    strValue = jsonValue.isString().stringValue();
                }//from w w w  .  j a v a2  s.com
                url.append("&").append(ProtocolTranslator.getFieldName(key)).append("=")
                        .append(URL.encodeQueryString(strValue));
            }
        }
        try {
            RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url.toString());
            requestBuilder.setCallback(new RequestCallback() {

                @Override
                public void onResponseReceived(Request request, Response response) {
                    // TODO call hitcallback if needed.
                }

                @Override
                public void onError(Request request, Throwable exception) {
                    // TODO Auto-generated method stub
                }
            });
            requestBuilder.send();
        } catch (RequestException e) {
        }
    }
}

From source file:com.arcbees.beestore.client.application.product.SharePanelPresenter.java

License:Apache License

@Override
protected void onReveal() {
    getView().updateShareUrls(URL.encodeQueryString(Window.Location.getHref()));
}

From source file:com.codenvy.ide.ext.java.client.documentation.QuickDocPresenter.java

License:Open Source License

@Override
public void showDocumentation() {
    EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
    if (activeEditor == null) {
        return;/*from   ww w . j a va2 s.  c  o  m*/
    }

    if (!(activeEditor instanceof EmbeddedTextEditorPresenter)) {
        Log.error(getClass(), "Quick Document support only EmbeddedTextEditorPresenter as editor");
        return;
    }

    EmbeddedTextEditorPresenter editor = ((EmbeddedTextEditorPresenter) activeEditor);
    int offset = editor.getCursorOffset();
    final PositionConverter.PixelCoordinates coordinates = editor.getPositionConverter().offsetToPixel(offset);

    worker.computeJavadocHandle(offset, editor.getEditorInput().getFile().getPath(),
            new JavaParserWorker.Callback<String>() {
                @Override
                public void onCallback(String result) {
                    if (result != null) {
                        result = URL.encodeQueryString(result);
                        view.show(
                                caContext + "/javadoc/" + appContext.getWorkspace().getId() + "/find?fqn="
                                        + result + "&projectpath="
                                        + appContext.getCurrentProject().getProjectDescription().getPath(),
                                coordinates.getX(), coordinates.getY() + 16);
                    }
                }
            });
}

From source file:com.codenvy.ide.ext.java.client.navigation.JavaNavigationServiceImpl.java

License:Open Source License

@Override
public void findDeclaration(String projectPath, String keyBinding,
        AsyncRequestCallback<OpenDeclarationDescriptor> callback) {
    String url = restContext + "/navigation/" + workspaceId + "/find-declaration?projectpath=" + projectPath
            + "&bindingkey=" + URL.encodeQueryString(keyBinding);
    requestFactory.createGetRequest(url).send(callback);
}

From source file:com.data2semantics.yasgui.client.helpers.ErrorHelper.java

License:Open Source License

/**
 * Display error when querying endpoint failed. Has buttons for opening query result page of endpoint itself on new page
 * //w ww. j  a v  a2s .  co  m
 * @param error Html error msg
 * @param endpoint Used endpoint
 * @param query Used query
 * @param args 
 */
public void onQueryError(String error, final String endpoint, final String query,
        final HashMultimap<String, String> args) {
    final Window window = getErrorWindow();
    window.setWidth(350);
    window.setZIndex(ZIndexes.MODAL_WINDOWS);
    VLayout vLayout = new VLayout();
    vLayout.setWidth100();
    Label label = new Label();
    label.setID("queryErrorMessage");
    label.setContents(error);
    label.setMargin(4);
    label.setHeight100();
    label.setWidth100();
    vLayout.addMember(label);

    HLayout buttons = new HLayout();
    buttons.setAlign(Alignment.CENTER);
    Button executeQuery = new Button("Open endpoint in new window");
    executeQuery.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            String url = endpoint + "?query=" + URL.encodeQueryString(query) + "&"
                    + Helper.getParamsAsString(args);
            com.google.gwt.user.client.Window.open(url, "_blank", null);
        }
    });
    executeQuery.setWidth(200);
    Button closeWindow = new Button("Close window");
    closeWindow.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            window.destroy();
        }
    });

    buttons.addMember(executeQuery);
    buttons.addMember(closeWindow);
    buttons.setWidth100();
    buttons.setLayoutAlign(Alignment.CENTER);
    vLayout.addMember(buttons);
    window.addItem(vLayout);
    window.draw();
}

From source file:com.data2semantics.yasgui.client.tab.optionbar.LinkCreator.java

License:Open Source License

private String getLink(TreeMap<String, String> args) {
    String url = JsMethods.getLocation();

    //remove these, as we will be adding these again
    url = Helper.removeArgumentsFromUrl(url, args.keySet());
    boolean firstItem = true;
    if (url.contains("?")) {
        firstItem = false;/*from www.  j  a  va  2s.co  m*/
    }
    Iterator<String> iterator = args.keySet().iterator();
    while (iterator.hasNext()) {
        if (firstItem) {
            url += "?";
            firstItem = false;
        } else {
            url += "&";
        }
        String key = iterator.next();
        String value = URL.encodeQueryString(args.get(key));
        url += key + "=" + value;
    }
    return url;

}

From source file:com.data2semantics.yasgui.client.ViewElements.java

License:Open Source License

/**
 * Display error when querying endpoint failed. Has buttons for opening query result page of endpoint itself on new page
 * //w  ww.  java 2s  .  co m
 * @param error Html error msg
 * @param endpoint Used endpoint
 * @param query Used query
 * @param args 
 */
public void onQueryError(String error, final String endpoint, final String query,
        final HashMap<String, String> args) {
    final Window window = getErrorWindow();
    window.setZIndex(ZIndexes.MODAL_WINDOWS);
    VLayout vLayout = new VLayout();
    vLayout.setWidth100();
    Label label = new Label(error);
    label.setMargin(4);
    label.setHeight100();
    label.setWidth100();
    vLayout.addMember(label);

    HLayout buttons = new HLayout();
    buttons.setAlign(Alignment.CENTER);
    Button executeQuery = new Button("Open endpoint in new window");
    executeQuery.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            String url = endpoint + "?query=" + URL.encodeQueryString(query);
            for (Entry<String, String> entry : args.entrySet()) {
                url += "&" + entry.getKey() + "=" + URL.encodeQueryString(entry.getValue());
            }
            com.google.gwt.user.client.Window.open(url, "_blank", null);
        }
    });
    executeQuery.setWidth(200);
    Button closeWindow = new Button("Close window");
    closeWindow.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            window.destroy();
        }
    });

    buttons.addMember(executeQuery);
    buttons.addMember(closeWindow);
    buttons.setWidth100();
    buttons.setLayoutAlign(Alignment.CENTER);
    vLayout.addMember(buttons);
    window.addItem(vLayout);
    window.setWidth(350);
    window.draw();
}

From source file:com.dawg6.web.dhcalc.client.GearPanel.java

License:Open Source License

protected void clickItem(Slot slot) {
    ItemHolder item = items.get(slot);//from w ww. j  av a 2 s  .c  o m

    if (item != null) {
        Window.open("json?realm=US&item=" + URL.encodeQueryString(item.tooltip), "_blank", "");
    }
}

From source file:com.dawg6.web.dhcalc.client.PaperdollPanel.java

License:Open Source License

public void load(Realm realm, String profile, int tag, int id) {

    StringBuilder params = new StringBuilder();
    params.append("realm=" + realm.name());
    params.append("&profile=" + URL.encodeQueryString(profile));
    params.append("&tag=" + tag);
    params.append("&id=" + id);

    frame.setUrl("paperdoll.jsp?" + params.toString());
}

From source file:com.dreamskiale.client.history.CustomHistorian.java

License:Apache License

/**
 * This method generates the url that will be used for updating the browser url.
 * // w  w w.j a  v a 2s.c o  m
 * @return A full path valid url properly escaped
 */
protected final String fromGwtPlaceTokenToUrl(String gwtPlaceToken) {
    String url;
    if (!isBlank(gwtPlaceToken)) {
        String[] prefixValue = gwtPlaceToken.split(":");
        url = prefixValue[0] + "/" + (prefixValue.length == 2 ? URL.encodeQueryString(prefixValue[1]) : "");
    } else {
        url = initialToken;
    }
    if (isBlank(url)) {
        url = "";
    }
    return getUrlSeparator() + url;
}