public class History extends Object
In order to receive notification of user-directed changes to the current
history item, implement the ValueChangeHandler
interface and attach
it via addValueChangeHandler(ValueChangeHandler)
.
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):
Constructor and Description |
---|
History() |
Modifier and Type | Method and Description |
---|---|
static void |
addHistoryListener(HistoryListener listener)
Deprecated.
use
addValueChangeHandler(ValueChangeHandler) instead |
static HandlerRegistration |
addValueChangeHandler(ValueChangeHandler<String> handler)
Adds a
ValueChangeEvent handler
to be informed of changes to the browser's history stack. |
static void |
back()
Programmatic equivalent to the user pressing the browser's 'back' button.
|
static String |
encodeHistoryToken(String historyToken)
Encode a history token for use as part of a URI.
|
static void |
fireCurrentHistoryState()
Fire
ValueChangeHandler.onValueChange(com.google.gwt.event.logical.shared.ValueChangeEvent)
events with the current history state. |
static void |
forward()
Programmatic equivalent to the user pressing the browser's 'forward'
button.
|
static String |
getToken()
Gets the current history token.
|
static void |
newItem(String historyToken)
Adds a new browser history entry.
|
static void |
newItem(String historyToken,
boolean issueEvent)
Adds a new browser history entry.
|
static void |
onHistoryChanged(String historyToken)
Deprecated.
Use
fireCurrentHistoryState() instead. |
static void |
removeHistoryListener(HistoryListener listener)
Deprecated.
|
static void |
replaceItem(String historyToken)
Replace the current history token on top of the browsers history stack.
|
static void |
replaceItem(String historyToken,
boolean issueEvent)
Replace the current history token on top of the browsers history stack.
|
@Deprecated public static void addHistoryListener(HistoryListener listener)
addValueChangeHandler(ValueChangeHandler)
insteadlistener
- the listener to be addedpublic static HandlerRegistration addValueChangeHandler(ValueChangeHandler<String> handler)
ValueChangeEvent
handler
to be informed of changes to the browser's history stack.handler
- the handlerpublic static void back()
public static String encodeHistoryToken(String historyToken)
historyToken
- the token to encodepublic static void fireCurrentHistoryState()
ValueChangeHandler.onValueChange(com.google.gwt.event.logical.shared.ValueChangeEvent)
events with the current history state. This is most often called at the end
of an application's
EntryPoint.onModuleLoad()
to inform
history handlers of the initial application state.public static void forward()
public static String getToken()
ValueChangeHandler.onValueChange(com.google.gwt.event.logical.shared.ValueChangeEvent)
event for the initial token; requiring that an application request the
token explicitly on startup gives it an opportunity to run different
initialization code in the presence or absence of an initial token.public static void newItem(String historyToken)
ValueChangeHandler.onValueChange(com.google.gwt.event.logical.shared.ValueChangeEvent)
to be called as well.historyToken
- the token to associate with the new history itempublic static void newItem(String historyToken, boolean issueEvent)
ValueChangeHandler.onValueChange(com.google.gwt.event.logical.shared.ValueChangeEvent)
to be called as well if and only if issueEvent is true.historyToken
- the token to associate with the new history itemissueEvent
- true if a
ValueChangeHandler.onValueChange(com.google.gwt.event.logical.shared.ValueChangeEvent)
event should be issued@Deprecated public static void onHistoryChanged(String historyToken)
fireCurrentHistoryState()
instead.fireCurrentHistoryState()
from the
application EntryPoint.onModuleLoad()
method.historyToken
- history token to fire events for@Deprecated public static void removeHistoryListener(HistoryListener listener)
listener
- the listener to be removedpublic static void replaceItem(String historyToken)
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.
Calling this method will cause
ValueChangeHandler.onValueChange(com.google.gwt.event.logical.shared.ValueChangeEvent)
to be called as well.
historyToken
- history token to replace current top entrypublic static void replaceItem(String historyToken, boolean issueEvent)
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.
Calling this method will cause
ValueChangeHandler.onValueChange(com.google.gwt.event.logical.shared.ValueChangeEvent)
to be called as well if and only if issueEvent is true.
historyToken
- history token to replace current top entryissueEvent
- issueEvent true if a
ValueChangeHandler.onValueChange(com.google.gwt.event.logical.shared.ValueChangeEvent)
event should be issuedCopyright © 2018. All rights reserved.