本文整理了Java中com.google.gwt.user.client.History
类的一些代码示例,展示了History
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。History
类的具体详情如下:
包路径:com.google.gwt.user.client.History
类名称:History
[英]This class allows you to interact with the browser's history stack. Each "item" on the stack is represented by a single string, referred to as a "token". You can create new history items (which have a token associated with them when they are created), and you can programmatically force the current history to move back or forward.
In order to receive notification of user-directed changes to the current history item, implement the ValueChangeHandler interface and attach it via #addValueChangeHandler(ValueChangeHandler).
com.google.gwt.examples.HistoryExample
Any valid characters may be used in the history token and will survive round-trips through #newItem(String) to #getToken()/ ValueChangeHandler#onValueChange(com.google.gwt.event.logical.shared.ValueChangeEvent), but most will be encoded in the user-visible URL. The following US-ASCII characters are not encoded on any currently supported browser (but may be in the future due to future browser changes):
代码示例来源:origin: kaaproject/kaa
/**
* Reset the current history.
*/
public void resetCurrentHistory() {
historyParams.clear();
String historyToken = UrlParams.generateParamsUrl(historyParams);
History.newItem(historyToken, false);
}
代码示例来源:origin: com.google.gwt/gwt-servlet
public com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler(
ValueChangeHandler<String> valueChangeHandler) {
return History.addValueChangeHandler(valueChangeHandler);
}
代码示例来源:origin: kaaproject/kaa
private void processHistory(ValueChangeEvent<String> event) {
String historyToken;
if (event != null) {
historyToken = event.getValue();
} else {
historyToken = History.getToken();
}
updateHistoryParamsFromToken(historyToken);
}
代码示例来源:origin: kaaproject/kaa
@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());
}
}
}
});
}
代码示例来源:origin: com.google.gwt/gwt-servlet
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);
}
}
}
代码示例来源:origin: com.google.gwt/gwt-servlet
/**
* 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();
}
}
代码示例来源:origin: org.eagle-i/eagle-i-search-gwt
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 );
}
}
代码示例来源:origin: org.jvnet.hudson.main/maven3-plugin
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();
}
}
代码示例来源:origin: bedatadriven/activityinfo
private void onNavigationCompleted(PageState place) {
String token = PageStateSerializer.serialize(place);
/*
* If it's a duplicate, we're not totally interested
*/
if (!token.equals(History.getToken())) {
/*
* Lodge in the browser's history
*/
History.newItem(token, false);
}
}
代码示例来源:origin: ArcBees/GWTP
@Override
public void navigateBack() {
History.back();
}
代码示例来源:origin: ltearno/hexa.tools
public void refreshCurrentPlace()
{
History.fireCurrentHistoryState();
}
代码示例来源:origin: bedatadriven/activityinfo
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()));
}
}
代码示例来源:origin: org.eagle-i/eagle-i-search-gwt
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;
代码示例来源:origin: com.google.gwt/gwt-servlet
/**
* 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);
}
}
}
代码示例来源:origin: com.google.gwt/gwt-servlet
/**
* 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);
}
代码示例来源:origin: com.googlecode.mgwt/mgwt
@Override
public void go(int number) {
if (number > 0) {
History.forward();
} else {
History.back();
}
}
代码示例来源:origin: org.eagle-i/eagle-i-search-gwt
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 );
}
}
代码示例来源:origin: com.haulmont.cuba/cuba-web-toolkit
protected void initHandler() {
handlerRegistration = History.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
History.fireCurrentHistoryState();
代码示例来源:origin: com.vaadin.external.gwt/gwt-user
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);
}
}
}
代码示例来源:origin: dennisjzh/GwtMobile-UI
@Override
public void goBack(Object returnValue) {
History.back();
}
内容来源于网络,如有侵权,请联系作者删除!