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:org.eobjects.datacleaner.monitor.wizard.DatastoreWizardController.java

License:Open Source License

@Override
protected void wizardFinished(final String datastoreName) {
    final String encodedDatastoreName = URL.encodeQueryString(datastoreName);

    final Button button = new Button("Close");
    button.addClickHandler(new ClickHandler() {
        @Override/*from   ww  w . ja v  a  2s  . co m*/
        public void onClick(ClickEvent event) {
            // full page refresh.
            closeWizardAfterFinishing(datastoreName, "datastores.jsf");
        }
    });

    final Anchor jobWizardAnchor = new Anchor("Build a job for this datastore");
    jobWizardAnchor.addStyleName("BuildJob");
    jobWizardAnchor.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final String htmlDivId = getWizardPanel().getCustomHtmlDivId();
            closeWizardAfterFinishing(datastoreName, null);

            JavaScriptCallbacks.startJobWizard(datastoreName, null, htmlDivId);
        }
    });

    final Anchor queryAnchor = new Anchor("Explore / query this datastore");
    queryAnchor.addStyleName("QueryDatastore");
    queryAnchor.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final String url = Urls.createRelativeUrl("query.jsf?ds=" + encodedDatastoreName);
            Window.open(url, "_blank", "location=no,width=770,height=400,toolbar=no,menubar=no");
        }
    });

    final FlowPanel contentPanel = new FlowPanel();
    contentPanel.addStyleName("WizardFinishedPanel");
    contentPanel.add(new Label("Datastore '" + datastoreName + "' created! Wizard finished."));

    contentPanel.add(new Label(
            "Click 'Close' to return, or click one of the links below to start using the datastore."));
    contentPanel.add(jobWizardAnchor);
    contentPanel.add(queryAnchor);

    setContent(contentPanel);
    getWizardPanel().getButtonPanel().clear();
    getWizardPanel().getButtonPanel().addButton(button);
    getWizardPanel().refreshUI();
}

From source file:org.freemedsoftware.gwt.client.Util.java

License:Open Source License

/**
 * Get full url of FreeMED JSON relay./*from  w  ww . j a  v a  2  s. c  o m*/
 * 
 * @param method
 *            Fully qualified method name
 * @param args
 *            Array of parameters, as strings
 * @return URL to pass with JSON request
 */
public static synchronized String getJsonRequest(String method, String[] args) {
    String url = getBaseUrl() + "/relay.php/json";
    if (GWT_HOSTED_MODE)
        url = getBaseUrl() + "/relay.jsp";
    try {
        String params = new String();
        for (int iter = 0; iter < args.length; iter++) {
            if (iter > 0) {
                params += "&";
            }
            params += "param" + new Integer(iter).toString() + "=" + URL.encodeQueryString(args[iter]);
        }
        if (GWT_HOSTED_MODE)
            return url + "?module=" + method + (params.length() > 0 ? "&" + params : "");
        else
            return url + "/" + method + "?" + params;
    } catch (Exception e) {
        return url + "/" + method;
    }
}

From source file:org.geosdi.geoplatform.gui.client.form.GPPrintWidget.java

License:Open Source License

private String getLegendUrl(GPLayerBean layer) {
    String dataSource = layer.getDataSource();

    if (dataSource.contains("gwc/service/wms")) {
        dataSource = dataSource.replaceAll("gwc/service/wms", "wms");
    } else if (!(dataSource.startsWith("http://ows")) && (dataSource.contains("/ows"))) {
        dataSource = dataSource.replaceAll("/ows", "/wms");
    } else {/* w  ww. jav a  2  s . c  om*/
        dataSource = dataSource.replaceAll("/wfs", "/wms");
    }

    String dataSourceT = dataSource;

    String style = this.getStyleFromLayer(layer);

    String imageURL = URL.encodeQueryString(
            dataSourceT + "?REQUEST=GetLegendGraphic" + "&VERSION=1.0.0&FORMAT=image/png&LAYER="
                    + URL.encode(layer.getName()) + "&STYLE=" + style + "&scale=5000&service=WMS");

    return imageURL;

}

From source file:org.geowe.client.local.layermanager.tool.create.GeoDataImportDialog.java

License:Open Source License

private SelectHandler createUrlToShare(final VerticalPanel geoDataContainer) {
    return new SelectHandler() {
        @Override//w ww  . j  a  va  2  s . c  om
        public void onSelect(SelectEvent event) {
            urlToShareAnchor.setHref(getHref());
            urlToShareAnchor.setText(UIMessages.INSTANCE.seeOtherWindow(getLayerName()), Direction.LTR);

            urlShared.setText(getHref());
            urlPanel.setVisible(true);
            urlShared.setVisible(true);
        }

        private String getHref() {
            String baseUrl = GWT.getHostPageBaseURL();

            baseUrl += "?layerUrl=" + URL.encodeQueryString(urlTextField.getValue()) + "&layerName="
                    + getLayerName() + "&layerProj=" + getProjectionName() + "&layerFormat=" + getDataFormat();

            return baseUrl;
        }
    };
}

From source file:org.geowe.client.local.main.tool.map.catalog.model.WfsVectorLayerDef.java

License:Open Source License

private String createWfsUrl() {
    StringBuffer url = new StringBuffer(serviceUrl);
    url.append("?request=GetFeature");
    url.append("&service=WFS");
    url.append("&version=" + version);
    url.append("&typeName=" + nameSpaceFeatureType);
    if (maxFeatures != 0) {
        url.append(getMaxFeaturesLimit());
    }/*from  www .  ja  v  a2  s .c o m*/
    if (!getFormat().isEmpty()) {
        url.append(getOutputFormat());
    }
    if (queryBbox) {
        url.append("&srsName=" + getEpsg());
        url.append("&bbox=" + bbox.getLowerLeftX() + "," + bbox.getLowerLeftY() + "," + bbox.getUpperRightX()
                + "," + bbox.getUpperRightY());
    } else {
        url.append("&CQL_FILTER=" + URL.encodeQueryString(cql));
    }
    return url.toString();
}

From source file:org.geowe.client.local.main.tool.project.OpenProjectDialog.java

License:Open Source License

private SelectHandler createUrlToShare(final VerticalPanel geoDataContainer) {
    return new SelectHandler() {
        @Override//from   w ww.  j  a  v a 2 s . c  o  m
        public void onSelect(SelectEvent event) {
            urlToShareAnchor.setHref(getHref());
            urlToShareAnchor.setText(UIMessages.INSTANCE.seeOtherWindow("GeoWE Project"), Direction.LTR);

            urlShared.setText(getHref());
            urlPanel.setVisible(true);
            urlShared.setVisible(true);
        }

        private String getHref() {
            String baseUrl = GWT.getHostPageBaseURL();

            baseUrl += "?projectUrl=" + URL.encodeQueryString(urlTextField.getValue());

            return baseUrl;
        }
    };
}

From source file:org.glimpse.client.news.NewsReader.java

License:Open Source License

public void refresh(boolean serverRefresh) {
    initialized = true;/*w w w.ja v  a2  s  .  c o m*/
    final String url = getUrl();
    entriesTable.clear();

    if (url == null || url.trim().equals("")) {
        optionPanel.setVisible(true);
        checkPreviousNext();
        return;
    } else {
        optionPanel.setVisible(false);
    }

    error.setVisible(false);
    loadingPanel.setVisible(true);
    checkPreviousNext();
    newsRetrieverService.getNewsChannel(url, serverRefresh, new AsyncCallback<NewsChannel>() {
        public void onFailure(Throwable caught) {
            loadingPanel.setVisible(false);
            error.setVisible(true);
        }

        public void onSuccess(NewsChannel channel) {
            loadingPanel.setVisible(false);
            if (channel != null) {
                String channelTitle = channel.getTitle();
                if (channelTitle.length() > 60) {
                    channelTitle = channelTitle.substring(0, 60) + "...";
                }
                title.setText(channelTitle);
                title.setHref(channel.getUrl());
                String encodedUrl = URL.encodeQueryString(channel.getUrl());
                titleImage.setUrl("servlets/news-icon?url=" + encodedUrl);
                entriesTable.setProperties(channel.getEntries(), getUrl(), getMaxPerPage(), isDirectOpen());
                checkPreviousNext();
            } else {
                error.setVisible(true);
            }
        }
    });
}

From source file:org.jahia.ajax.gwt.client.core.BaseAsyncCallback.java

License:Open Source License

public void showLogin() {
    GWT.runAsync(new RunAsyncCallback() {
        public void onFailure(Throwable reason) {
        }/* ww  w . j  a  v a 2 s  . co  m*/

        public void onSuccess() {
            final String loginUrl = CommonEntryPoint.getLoginUrl();
            if (loginUrl != null && !loginUrl.isEmpty()) {
                Window.Location.assign(loginUrl + (loginUrl.contains("?") ? "&" : "?") + "redirect="
                        + URL.encodeQueryString(Window.Location.getHref()));
            } else {
                if (!LoginBox.getInstance().isVisible()) {
                    LoginBox.getInstance().show();

                }
            }
        }
    });
}

From source file:org.jahia.ajax.gwt.client.widget.edit.mainarea.MainModule.java

License:Open Source License

/**
 * Appends the current URL query string (if present) to the specified one.
 *//* w ww  . ja  va2 s . c o m*/
private static void appendQueryString(StringBuilder url) {
    List<String[]> paramsToPreserve = getQueryStringParametersToPreserve(RESERVED_REQUESTPARAMETERS);

    if (paramsToPreserve == null || paramsToPreserve.isEmpty()) {
        // no query string available
        return;
    }

    url.append(url.indexOf("?") == -1 ? '?' : '&');
    boolean first = true;
    for (String[] p : paramsToPreserve) {
        if (!first) {
            url.append('&');
        } else {
            first = false;
        }
        url.append(p[0]).append('=').append(URL.encodeQueryString(p[1]));
    }
}

From source file:org.jboss.errai.mvp.client.places.ParameterTokenFormatter.java

License:Apache License

/**
 * Use our custom escaping mechanism to escape the provided string. This should be used on the
 * name token, and the parameter keys and values, before they are attached with the various
 * separators. The string will also be passed through {@link com.google.gwt.http.client.URL#encodeQueryString}.
 * Visible for testing.//from  w  w  w .j  a  v a2s.  com
 * @param string The string to escape.
 * @return The escaped string.
 */
String customEscape(String string) {
    StringBuffer sbuf = new StringBuffer();
    int len = string.length();

    char hierarchyChar = hierarchySeparator.charAt(0);
    char paramChar = paramSeparator.charAt(0);
    char valueChar = valueSeparator.charAt(0);

    for (int i = 0; i < len; i++) {
        char ch = string.charAt(i);
        if (ch == ESCAPE_CHARACTER) {
            sbuf.append(ESCAPED_ESCAPE_CHAR);
        } else if (ch == hierarchyChar) {
            sbuf.append(ESCAPED_HIERARCHY_SEPARATOR);
        } else if (ch == paramChar) {
            sbuf.append(ESCAPED_PARAM_SEPARATOR);
        } else if (ch == valueChar) {
            sbuf.append(ESCAPED_VALUE_SEPARATOR);
        } else {
            sbuf.append(ch);
        }
    }

    return URL.encodeQueryString(sbuf.toString());
}