Class BrowsingHistoryBase
java.lang.Object
dev.webfx.platform.windowhistory.spi.impl.BrowsingHistoryBase
- All Implemented Interfaces:
BrowsingHistory
- Direct Known Subclasses:
MemoryBrowsingHistory
,SubBrowsingHistory
- Author:
- Bruno Salmon
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncheckBeforeAsync
(BrowsingHistoryLocation location) protected Future<BrowsingHistoryLocationImpl>
checkBeforeThenTransit
(PathStateLocation location, BrowsingHistoryEvent event) protected boolean
checkBeforeUnload
(BrowsingHistoryLocation location) protected Future<BrowsingHistoryLocationImpl>
createHistoryLocation
(PathStateLocation pathStateLocation, BrowsingHistoryEvent event) createHistoryLocation
(String path, ReadOnlyAstObject state) protected String
createPathStateLocation
(String path, ReadOnlyAstObject state) protected void
doAcceptedPop
(BrowsingHistoryLocationImpl historyLocation) protected abstract void
doAcceptedPush
(BrowsingHistoryLocationImpl historyLocation) protected abstract void
doAcceptedReplace
(BrowsingHistoryLocationImpl historyLocation) protected void
fireLocationChanged
(BrowsingHistoryLocation location) protected String
fullToMountPath
(String fullPath) protected String
getPath
(PathStateLocation location) Creating URLs ******************************************************* Additionally, history objects can be used to create URL paths and/or hrefs for<a>
tags that link to various places in your app.boolean
void
listen
(Handler<BrowsingHistoryLocation> listener) Listen for changes to the current location.void
listenBeforeAsync
(Function<BrowsingHistoryLocation, Future<Boolean>> transitionHook) If your transition hook needs to execute asynchronously, you can return a future boolean.void
listenBeforeUnload
(Function<BrowsingHistoryLocation, Boolean> transitionHook) A before unload hook is a function that is used in web browsers to prevent the user from navigating away from the page or closing the window.protected String
mountToFullPath
(String mountPath) void
push
(PathStateLocation location) Push a new entry onto the history stack.void
replace
(PathStateLocation location) Replace the current entry on the history stack.protected void
setGoingBackward
(boolean goingBackward) void
setMountPoint
(String mountPoint) protected void
transit
(BrowsingHistoryLocationImpl newHistoryLocation) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.webfx.platform.windowhistory.spi.BrowsingHistory
getCurrentLocation, go, goBack, goForward, listenBefore, push, push, replace, replace, transitionTo
-
Constructor Details
-
BrowsingHistoryBase
public BrowsingHistoryBase()
-
-
Method Details
-
setMountPoint
-
getMountPoint
-
mountToFullPath
-
fullToMountPath
-
push
Description copied from interface:BrowsingHistory
Push a new entry onto the history stack.- Specified by:
push
in interfaceBrowsingHistory
- Parameters:
location
- A location descriptor object that uses a combination of pathname, search, hash, and state properties
-
replace
Description copied from interface:BrowsingHistory
Replace the current entry on the history stack.- Specified by:
replace
in interfaceBrowsingHistory
- Parameters:
location
- A location descriptor object that uses a combination of pathname, search, hash, and state properties
-
checkBeforeUnloadThenCheckBeforeThenTransit
protected Future<BrowsingHistoryLocationImpl> checkBeforeUnloadThenCheckBeforeThenTransit(PathStateLocation location, BrowsingHistoryEvent event) -
checkBeforeThenTransit
protected Future<BrowsingHistoryLocationImpl> checkBeforeThenTransit(PathStateLocation location, BrowsingHistoryEvent event) -
setGoingBackward
protected void setGoingBackward(boolean goingBackward) -
isGoingBackward
public boolean isGoingBackward()- Specified by:
isGoingBackward
in interfaceBrowsingHistory
-
transit
-
doAcceptedPush
-
doAcceptedReplace
-
doAcceptedPop
-
createLocationKey
-
getPath
Description copied from interface:BrowsingHistory
Creating URLs ******************************************************* Additionally, history objects can be used to create URL paths and/or hrefs for<a>
tags that link to various places in your app. This is useful when using hash history to prefix URLs with a # or when using query support to automatically build query strings. String href = history.createHref('/the/path')- Specified by:
getPath
in interfaceBrowsingHistory
-
createPathStateLocation
- Specified by:
createPathStateLocation
in interfaceBrowsingHistory
-
createHistoryLocation
- Specified by:
createHistoryLocation
in interfaceBrowsingHistory
-
createHistoryLocation
public BrowsingHistoryLocationImpl createHistoryLocation(PathStateLocation pathStateLocation, BrowsingHistoryEvent event) -
listen
Description copied from interface:BrowsingHistory
Listen for changes to the current location.- Specified by:
listen
in interfaceBrowsingHistory
-
listenBeforeAsync
Description copied from interface:BrowsingHistory
If your transition hook needs to execute asynchronously, you can return a future boolean. Note: If you do provide a callback argument, the transition will not proceed until you call it (i.e. listeners will not be notified of the new location)! If your app is slow for some reason, this could lead to a non-responsive UI.- Specified by:
listenBeforeAsync
in interfaceBrowsingHistory
- Parameters:
transitionHook
- a hook asynchronous function that takes the location and returns a future boolean that will tell if the transition accepted (true) or prevented (false)
-
listenBeforeUnload
Description copied from interface:BrowsingHistory
A before unload hook is a function that is used in web browsers to prevent the user from navigating away from the page or closing the window. history.listenBeforeUnload(() -> 'Are you sure you want to leave this page?'); Note that because of the nature of the beforeunload event all hooks must return synchronously. BrowsingHistory runs all hooks in the order they were registered and displays the first message that is returned.- Specified by:
listenBeforeUnload
in interfaceBrowsingHistory
-
checkBeforeUnload
-
checkBeforeAsync
-
fireLocationChanged
-