private void redirectToModule(String module) { String path = Window.Location.getPath(); if (!path.endsWith("/")) { if (path.endsWith(".html") || path.endsWith(".htm")) { int index = path.lastIndexOf('/'); path = path.substring(0, index + 1); } else { path += "/"; } } String target = path + module + "/"; Window.Location.assign(Window.Location.createUrlBuilder().setPath(target).buildString()); }
UrlBuilder builder = new UrlBuilder(); builder.setProtocol(getProtocol()); builder.setHost(getHost()); String path = getPath(); if (path != null && path.length() > 0) { builder.setPath(path); builder.setHash(URL.decodeQueryString(hash)); builder.setPort(Integer.parseInt(port)); for (Map.Entry<String, List<String>> entry : params.entrySet()) { List<String> values = new ArrayList<String>(entry.getValue()); builder.setParameter(entry.getKey(), values.toArray(new String[values.size()]));
UrlBuilder u = new UrlBuilder(); u.setProtocol("https"); u.setHost("www.mysite.com:8080"); u.setPath("/myServletPath"); u.setParameter("username", nameField.getValue()); u.setParameter("someAttribute", "itsValue"); u.buildString();
@Override public void addGraphToReport(final RequestCallback callback, final int kscReportId, final String graphTitle, final String graphName, final String resourceId, final String timeSpan) { UrlBuilder builder = new UrlBuilder(); builder.setPath(BASE_URL + "/" + kscReportId); builder.setParameter("title", graphTitle); builder.setParameter("reportName", graphName); builder.setParameter("resourceId", resourceId); builder.setParameter("timespan", timeSpan); // we just want a relative URL, so we render it and strip the beginning :) final String url = builder.buildString().replace("http:///", ""); GWT.log("making request: " + url); sendRequest(callback, RequestBuilder.PUT, url); }
public static String localeUrl(ApplicationLocale applicationLocale) { // We use the sub-delim '+' extensively in fragment identifiers, // for example: // #data-entry/Activity+53432 // UrlBuilder will decode and re-encode this resulting in // #data-entry/Activity%2053432 // Which will break navigation // So we will first construct the url without the hash, // and then append the already-encoded fragment identifier directly String url = Window.Location.createUrlBuilder() .setParameter("locale", applicationLocale.getCode()) .setHash(null) .buildString(); return url + Window.Location.getHash(); }
private void setCurrentLanguage( final String languageName, final UserWorkbenchPreferences response ) { String isRefresh = Window.Location.getParameter( "isRefresh" ); if ( response != null && ( isRefresh == null || isRefresh.equals( "" ) ) ) { Window.Location.assign( Window.Location.createUrlBuilder() .removeParameter( getLocaleQueryParam() ) .setParameter( getCurrentLocaleQueryParam(), languageName ) .setParameter( "isRefresh", "false" ) .buildString() ); } else if ( response == null ) { Window.Location.assign( Window.Location.createUrlBuilder() .removeParameter( getLocaleQueryParam() ) .setParameter( getCurrentLocaleQueryParam(), languageName ) .buildString() ); } }
@Override public void replaceState(String data, String title, String url) { UrlBuilder builder = Window.Location.createUrlBuilder(); builder.setHash(data); Window.Location.replace(builder.buildString()); }
public static void showSampleInNewTab(ShowcaseSampleDefinition sample) { UrlBuilder urlBuilder = Window.Location.createUrlBuilder(); urlBuilder.setParameter("sample", sample.getKey()); String url = urlBuilder.buildString(); Window.open(url, sample.getTitle(), ""); }
private void onImport(SelectEvent event) { // Redirect to old app for the moment. UrlBuilder importUrl = Window.Location.createUrlBuilder(); importUrl.setHash("#import/" + viewModel.getFormId().asString()); importUrl.removeParameter("ui"); Window.open(importUrl.buildString(), "_blank", null); }
@Override public String buildString() { return b.buildString(); }
@Override public IsUrlBuilder setParameter(String key, String... values) { b.setParameter(key, values); return this; }
URL url = new UrlBuilder("http://www.example.com/api/Video/GetListMusicRelated") .myParam1(25) .myParam2("jim") .build();
@Override public IsUrlBuilder setPath(String path) { b.setPath(path); return this; }
@Override public IsUrlBuilder setHash(String hash) { b.setHash(hash); return this; }
UrlBuilder builder = new UrlBuilder() .setProtocol(Window.Location.getProtocol()) .setHost(Window.Location.getHost()) .setPath(ApiPaths.FORM + id); downloadFrame.setUrl(builder.build());
/** * Set the host portion of the location (ex. google.com). You can also specify * the port in this method (ex. localhost:8888). * * @param host the host */ public UrlBuilder setHost(String host) { // Extract the port from the host. if (host != null && host.contains(":")) { String[] parts = host.split(":"); if (parts.length > 2) { throw new IllegalArgumentException( "Host contains more than one colon: " + host); } try { setPort(Integer.parseInt(parts[1])); } catch (NumberFormatException e) { throw new IllegalArgumentException("Could not parse port out of host: " + host); } host = parts[0]; } this.host = host; return this; }
@Override public IsUrlBuilder setProtocol(String protocol) { b.setProtocol(protocol); return this; }
@Override public IsUrlBuilder setHost(String host) { b.setHost(host); return this; }
@Override public IsUrlBuilder removeParameter(String name) { b.removeParameter(name); return this; }
public static String localeUrl(ApplicationLocale applicationLocale) { // We use the sub-delim '+' extensively in fragment identifiers, // for example: // #data-entry/Activity+53432 // UrlBuilder will decode and re-encode this resulting in // #data-entry/Activity%2053432 // Which will break navigation // So we will first construct the url without the hash, // and then append the already-encoded fragment identifier directly String url = Window.Location.createUrlBuilder() .setParameter("locale", applicationLocale.getCode()) .setHash(null) .buildString(); return url + Window.Location.getHash(); }