Example usage for com.vaadin.shared.util SharedUtil addGetParameters

List of usage examples for com.vaadin.shared.util SharedUtil addGetParameters

Introduction

In this page you can find the example usage for com.vaadin.shared.util SharedUtil addGetParameters.

Prototype

public static String addGetParameters(String uri, String extraParams) 

Source Link

Document

Adds the get parameters to the uri and returns the new uri that contains the parameters.

Usage

From source file:org.vaadin.addon.ewopener.client.EnhancedBrowserWindowOpenerConnector.java

License:Apache License

private String addParametersAndFragment(String url) {
    if (url == null) {
        return null;
    }//from   w  w w . ja  v a  2  s .com

    if (!getState().parameters.isEmpty()) {
        StringBuilder params = new StringBuilder();
        for (Map.Entry<String, String> entry : getState().parameters.entrySet()) {
            if (params.length() != 0) {
                params.append('&');
            }
            params.append(URL.encodeQueryString(entry.getKey()));
            params.append('=');

            String value = entry.getValue();
            if (value != null) {
                params.append(URL.encodeQueryString(value));
            }
        }

        url = SharedUtil.addGetParameters(url, params.toString());
    }

    if (getState().uriFragment != null) {
        // Replace previous fragment or just add to the end of the url
        url = url.replaceFirst("#.*|$", "#" + getState().uriFragment);
    }

    return url;
}