/** * Reset the current history. */ public void resetCurrentHistory() { historyParams.clear(); String historyToken = UrlParams.generateParamsUrl(historyParams); History.newItem(historyToken, false); }
public com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler( ValueChangeHandler<String> valueChangeHandler) { return History.addValueChangeHandler(valueChangeHandler); }
private void processHistory(ValueChangeEvent<String> event) { String historyToken; if (event != null) { historyToken = event.getValue(); } else { historyToken = History.getToken(); } updateHistoryParamsFromToken(historyToken); }
@Override public void onModuleLoad() { HistoryHandler historyHandler = new HistoryHandler(); History.addValueChangeHandler(historyHandler); updateHistoryParamsFromToken(History.getToken()); authService.checkAuth(new AsyncCallback<AuthResultDto>() { @Override public void onFailure(Throwable caught) { authResult = Result.ERROR; showLogin(); Utils.handleException(caught, view); } @Override public void onSuccess(AuthResultDto result) { authResult = result.getAuthResult(); if (authResult == Result.OK) { redirectToModule("kaaAdmin"); } else { showLogin(); if (authResult == Result.ERROR) { view.setErrorMessage(Utils.messages.unexpectedError()); } else if (authResult == Result.KAA_ADMIN_NOT_EXISTS) { view.setInfoMessage(Utils.messages.kaaAdminNotExists()); } } } }); }
private static void onHashChanged() { /* * We guard against firing events twice, some browser (e.g. safari) tend to * fire events on startup if HTML5 pushstate is used. */ String hashToken = getDecodedHash(); if (!hashToken.equals(getToken())) { token = hashToken; historyEventSource.fireValueChangedEvent(hashToken); } } }
/** * Replace the current history token on top of the browsers history stack. * * <p>Note: This method has problems. The URL is updated with window.location.replace, * this unfortunately has side effects when using the deprecated iframe linker * (ie. "std" linker). Make sure you are using the cross site iframe linker when using * this method in your code. * * <p>Calling this method will cause * {@link ValueChangeHandler#onValueChange(com.google.gwt.event.logical.shared.ValueChangeEvent)} * to be called as well if and only if issueEvent is true. * * @param historyToken history token to replace current top entry * @param issueEvent issueEvent true if a * {@link ValueChangeHandler#onValueChange(com.google.gwt.event.logical.shared.ValueChangeEvent)} * event should be issued */ public static void replaceItem(String historyToken, boolean issueEvent) { token = historyToken; impl.replaceToken(encodeHistoryToken(historyToken)); if (issueEvent) { fireCurrentHistoryState(); } }
private void update(final String pageParams) { if ( pageMode == null ) { // FIXME seriously revisit exception handling in the search UI throw new RuntimeException( "Cannot set history" ); } final StringBuilder buf = new StringBuilder( pageMode.getToken() ); if ( pageParams != null && pageParams.length() > 0 ) { // Use the standard ? to signal the start of the query parameters buf.append( pageParams ); } String newPageParams = buf.toString(); String currentPageParams = getCurrentPageParams(); if ( currentPageParams.equals( newPageParams ) ) { History.fireCurrentHistoryState(); } else { History.newItem( newPageParams ); } }
private void startHistoryManagement() { // Manage history change/navigation. // TODO: figure out how this fits in with Activities and Places. // TODO: probably pull this into a separate component. History.addValueChangeHandler(new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> event) { String historyToken = event.getValue(); // Find the module matching the history token. if (historyToken.startsWith("module-")) { String moduleId = historyToken.substring("module-".length()); for (MavenProjectDTO module : mdp.getList()) { if (moduleId.equals(module.getId())) { moduleInfoPickerPresenter.selectModule(module); // Show the module info tab. mainPanel.selectModuleInfo(); break; } } } } }); // Navigate to initial history state (as determined by the URL). History.fireCurrentHistoryState(); } }
@Override public void navigateBack() { History.back(); }
public void refreshCurrentPlace() { History.fireCurrentHistoryState(); }
private void fireInitialPage() { if (History.getToken().length() != 0) { Log.debug("HistoryManager: firing initial placed based on intial token: " + History.getToken()); History.fireCurrentHistoryState(); } else { eventBus.fireEvent(new NavigationEvent( NavigationHandler.NAVIGATION_REQUESTED, new DashboardPlace())); } }
public void clearHistory() { final String historyPageMode = getPageModeFromHistory( History.getToken() ); resultAnalytics = new SearchResultAnalytics(); if ( historyPageMode.isEmpty() ) { final String pageParam = getPageParamFromHistory( History.getToken() ); if ( PageMode.instance.pageToken.startsWith( historyPageMode ) ){ pageMode = PageMode.instance; Window.alert("Invalid URL, cannot display resource."); log.severe("Expecting exactly 2 parts after split, found: " + parts.length + ". Parts: " + parts); History.back(); return; Window.alert("Invalid URL, cannot display resource."); log.severe("Expecting first part to be " + URI_KEY + ", found: " + parts[0]); History.back(); return; Window.alert("Invalid URL, cannot display resource."); log.severe("Unexpected page token: "+pageMode); History.back(); return;
/** * Adds a new browser history entry. Calling this method will cause * {@link ValueChangeHandler#onValueChange(com.google.gwt.event.logical.shared.ValueChangeEvent)} * to be called as well if and only if issueEvent is true. * * @param historyToken the token to associate with the new history item * @param issueEvent true if a * {@link ValueChangeHandler#onValueChange(com.google.gwt.event.logical.shared.ValueChangeEvent)} * event should be issued */ public static void newItem(String historyToken, boolean issueEvent) { historyToken = (historyToken == null) ? "" : historyToken; if (!historyToken.equals(getToken())) { token = historyToken; String updateToken = encodeHistoryToken(historyToken); impl.newToken(updateToken); if (issueEvent) { historyEventSource.fireValueChangedEvent(historyToken); } } }
/** * Sets the history token referenced by this hyperlink. This is the history * token that will be passed to {@link History#newItem} when this link is * clicked. * * @param targetHistoryToken the new history token, which may not be null (use * {@link Anchor} instead if you don't need history processing) */ @SuppressIsSafeUriCastCheck //TODO(bangert): Refactor setPropertyString public void setTargetHistoryToken(String targetHistoryToken) { assert targetHistoryToken != null : "targetHistoryToken must not be null, consider using Anchor instead"; this.targetHistoryToken = targetHistoryToken; String hash = History.encodeHistoryToken(targetHistoryToken); anchorElem.setPropertyString("href", "#" + hash); }
public void updateCurrentRequest(final StemCellSearchRequest request, boolean redraw) { // TODO validate request if(redraw) { if(currentPageParamString.equals( request.toUrlParams() ) ) { History.fireCurrentHistoryState(); } else { History.newItem( currentPageMode.getToken() + request.toUrlParams() ); } } else { // Need to still update internal state and add a history item // just don't fire an event setInternalRequestState( request.toUrlParams() ); History.newItem( currentPageMode.getToken() + request.toUrlParams(), false ); } }
protected void initHandler() { handlerRegistration = History.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { History.fireCurrentHistoryState();
private static void onHashChanged() { /* * We guard against firing events twice, some browser (e.g. safari) tend to * fire events on startup if HTML5 pushstate is used. */ String hashToken = getDecodedHash(); if (!hashToken.equals(getToken())) { token = hashToken; historyEventSource.fireValueChangedEvent(hashToken); } } }
@Override public void goBack(Object returnValue) { History.back(); }