List of usage examples for com.google.gwt.http.client UrlBuilder setHash
public UrlBuilder setHash(String hash)
From source file:ch.unifr.pai.twice.multipointer.client.ExtendedWebsocketControl.java
License:Apache License
@Override public void start() { if (!isInIFrame()) { initializeCursorList();/* w ww .ja v a 2s . c om*/ if (r != null) r.removeHandler(); r = Window.addResizeHandler(this); UrlBuilder b = Window.Location.createUrlBuilder(); b.setProtocol("ws"); b.setPath("mouseControlXBrowser"); b.setHash(null); String p = Window.Location.getPort(); Integer port; try { port = p != null ? Integer.parseInt(p) : 8080; } catch (NumberFormatException e) { port = 8080; } b.setPort(port + 1); for (String param : Window.Location.getParameterMap().keySet()) { b.removeParameter(param); } websocket = createWebsocket(this, b.buildString()); if (websocket != null) createOnBeforeUnloadHandler(websocket); } }
From source file:com.googlecode.mgwt.mvp.client.history.HTML5HistorianLegacyImpl.java
License:Apache License
@Override public void replaceState(String data, String title, String url) { UrlBuilder builder = Window.Location.createUrlBuilder(); builder.setHash(data); Window.Location.replace(builder.buildString()); }
From source file:com.tasktop.c2c.server.common.profile.web.client.place.AbstractPlace.java
License:Open Source License
public String getHref() { if (!GWT.isClient()) { // For tests return "http://localhost/#" + getHistoryToken(); }//from ww w . ja va 2 s.com UrlBuilder urlBuilder = Window.Location.createUrlBuilder(); urlBuilder.setPath(Path.getBasePath()); return urlBuilder.setHash(getHistoryToken()).buildString(); }
From source file:gov.wa.wsdot.search.client.SearchWidget.java
License:Open Source License
/** * This method is called whenever the application's history changes. * //from w w w . j a v a 2 s . com * Calling the History.newItem(historyToken) method causes a new history entry to be * added which results in ValueChangeEvent being called as well. */ @Override public void onValueChange(ValueChangeEvent<String> event) { String url = JSON_URL; String url_flickr = JSON_URL_FLICKR; String url_highway_alerts = JSON_URL_HIGHWAY_ALERTS; String historyToken = event.getValue(); // This handles the initial GET call to the page. Rewrites the ?q= to #q= String queryParameter = Window.Location.getParameter("q"); if (queryParameter != null) { UrlBuilder urlBuilder = Window.Location.createUrlBuilder().removeParameter("q"); urlBuilder.setHash(historyToken); String location = urlBuilder.buildString(); Window.Location.replace(location); } String[] tokens = historyToken.split("&"); // e.g. #q=Ferries&p=2 Map<String, String> map = new HashMap<String, String>(); for (String string : tokens) { try { map.put(string.split("=")[0], string.split("=")[1]); } catch (ArrayIndexOutOfBoundsException e) { // TODO: Need a better way to handle this. } } String query = map.get("q"); String page = map.get("p"); if (page == null) { page = "1"; } searchSuggestBox.setText(query); String searchString = SafeHtmlUtils .htmlEscape(searchSuggestBox.getText().trim().replace("'", "").replace("\"", "")); loadingImage.setVisible(true); searchSuggestBox.setFocus(true); leftNavBoxHTMLPanel.setVisible(false); photosDisclosurePanel.setVisible(false); boostedResultsHTMLPanel.setVisible(false); alertsDisclosurePanel.setVisible(false); if (searchString.isEmpty()) { clearPage(); loadingImage.setVisible(false); bingLogoHTMLPanel.setVisible(false); } else { if (ANALYTICS_ENABLED) { Analytics.trackEvent(EVENT_TRACKING_CATEGORY, "Keywords", searchString.toLowerCase()); } clearPage(); // Append the name of the callback function to the JSON URL. url += searchString; url += "&page=" + page; url = URL.encode(url); // Append search query to Flickr url. url_flickr += searchString; url_flickr = URL.encode(url_flickr); // Send requests to remote servers with calls to JSNI methods. getSearchData(url, searchString, page); getPhotoData(url_flickr, searchString); getHighwayAlertsData(url_highway_alerts, searchString); } }
From source file:mx.org.pescadormvp.core.client.placesandactivities.PescadorMVPPlaceMapperImpl.java
License:Open Source License
@Override public void setupURLInfo(PescadorMVPPlace place) { String historyTokenFromPlaceObj = place.getHistoryToken(); String historyToken = historyTokenFromPlaceObj == null ? getToken(place) : historyTokenFromPlaceObj; place.setHistoryToken(historyToken); PescadorMVPLocale newLocale = place.getNewLocale(); if (newLocale == null) { place.setURL("#" + historyToken); // instructs Session not to reload the whole app when going here place.setRequiresReload(false);// www . j av a 2 s . co m } else { // TODO check that the locale is not the same as the current one (?) String queryParam = LocaleInfo.getLocaleQueryParam(); UrlBuilder builder = Location.createUrlBuilder(); builder.setParameter(queryParam, newLocale.getLocaleName()); builder.setHash(historyToken); place.setURL(builder.buildString()); // in this case, do reload the whole app when going here place.setRequiresReload(true); } }
From source file:uk.ac.ncl.openlab.intake24.client.survey.FlatFinalPage.java
License:Apache License
@Override public SimpleSurveyStageInterface getInterface(Callback1<Survey> onComplete, Callback2<Survey, Boolean> onIntermediateStateChange) { final CompletedSurvey finalData = data.finalise(log); final FlowPanel contents = new FlowPanel(); contents.addStyleName("intake24-survey-content-container"); contents.add(new LoadingPanel(messages.submitPage_loadingMessage())); SurveyService.INSTANCE.submitSurvey(EmbeddedData.surveyId, finalData, new MethodCallback<SurveySubmissionResponse>() { @Override/*w ww . j ava 2 s . c om*/ public void onFailure(Method method, Throwable exception) { contents.clear(); if (exception instanceof RequestTimeoutException) { final MethodCallback<SurveySubmissionResponse> outer = this; contents.add( new HTMLPanel(SafeHtmlUtils.fromSafeConstant(messages.submitPage_timeout()))); contents.add(WidgetFactory.createGreenButton(messages.submitPage_tryAgainButton(), "finalPageTryAgainButton", new ClickHandler() { @Override public void onClick(ClickEvent event) { SurveyService.INSTANCE.submitSurvey(EmbeddedData.surveyId, finalData, outer); } })); } else { contents.add( new HTMLPanel(SafeHtmlUtils.fromSafeConstant(messages.submitPage_error()))); } contents.add(new HTMLPanel(finalPageHtml)); } @Override public void onSuccess(Method method, SurveySubmissionResponse response) { contents.clear(); HTMLPanel p = new HTMLPanel(SafeHtmlUtils.fromSafeConstant(messages.submitPage_success())); p.getElement().getStyle().setMarginBottom(30, Style.Unit.PX); contents.add(p); if (response.redirectToFeedback) { HTMLPanel p1 = new HTMLPanel("h4", surveyMessages.finalPage_feedbackLabel()); p1.getElement().getStyle().setMarginBottom(0, Style.Unit.PX); contents.add(p1); Button feedbackButton = WidgetFactory.createGreenButton( surveyMessages.finalPage_feedbackButtonLabel(), "feedbackButton", new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { UrlBuilder builder = Window.Location.createUrlBuilder(); for (String paramName : Window.Location.getParameterMap().keySet()) { builder.removeParameter(paramName); } builder.setPath(Window.Location.getPath() + "/feedback"); builder.setHash("/"); Window.open(builder.buildString(), "_blank", ""); } }); contents.add(feedbackButton); } response.followUpUrl.accept(new Option.SideEffectVisitor<String>() { @Override public void visitSome(String url) { if (response.redirectToFeedback) { HTMLPanel p2 = new HTMLPanel("h4", surveyMessages.finalPage_externalFollowUpLabel_afterFeedback()); p2.getElement().getStyle().setMarginBottom(0, Style.Unit.PX); contents.add(p2); } else { HTMLPanel p2 = new HTMLPanel("h4", surveyMessages.finalPage_externalFollowUpLabel_noFeedback()); p2.getElement().getStyle().setMarginBottom(0, Style.Unit.PX); contents.add(p2); } FlowPanel externalLinkDiv = new FlowPanel(); externalLinkDiv.add(WidgetFactory.createGreenButton( surveyMessages.finalPage_externalFollowUpButtonLabel(), "finalPageExternalUrlButton", new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { Window.open(url, "_blank", ""); } })); contents.add(externalLinkDiv); } @Override public void visitNone() { } }); contents.add(new HTMLPanel(finalPageHtml)); UxEventsHelper.cleanSessionId(); StateManagerUtil.clearLatestState(AuthCache.getCurrentUserId()); } }); return new SimpleSurveyStageInterface(contents, FlatFinalPage.class.getSimpleName()); }