Class sap.ui.core.routing.HashChangerModule: sap/ui/core/routing/HashChanger


Class for manipulating and receiving changes of the browserhash with the hasher framework. Fires a "hashChanged" event if the browser hash changes.

Constructor Summary
Event Summary
hashChanged(oEvent)The 'hashChanged' event is fired when the URL hash is changed
hashReplaced(oEvent)The 'hashReplaced' event is fired when sap.ui.core.routing.HashChanger#replaceHash is called
hashSet(oEvent)The 'hashSet' event is fired when sap.ui.core.routing.HashChanger#setHash is called
Method Summary
sap.ui.core.routing.HashChanger.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.core.routing.HashChanger with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.core.routing.HashChanger.getInstance()Gets a global singleton of the HashChanger.
sap.ui.core.routing.HashChanger.getMetadata()Returns a metadata object for class sap.ui.core.routing.HashChanger.
sap.ui.core.routing.HashChanger.replaceHashChanger(oHashChanger)Sets the hashChanger to a new instance, destroys the old one and copies all its event listeners to the new one
destroy()Cleans the event registration
fireHashChanged(newHash, oldHash)Fires the hashchanged event, may be extended to modify the hash before fireing the event
getHash()Gets the current hash
init()Will start listening to hashChanges with the parseHash function.
replaceHash(sHash)Replaces the hash to a certain value.
setHash(sHash)Sets the hash to a certain value.
Methods borrowed from class sap.ui.base.Object
Constructor Detail
new sap.ui.core.routing.HashChanger()
Event Detail
hashChanged(oEvent)
The 'hashChanged' event is fired when the URL hash is changed
Parameters:
{sap.ui.base.Event}oEvent
{sap.ui.base.EventProvider}oEvent.getSource
{object}oEvent.getParameters
{string}oEvent.getParameters.oldHash The URL hash before it's changed
{object}oEvent.getParameters.newHash The new URL hash
hashReplaced(oEvent)
The 'hashReplaced' event is fired when sap.ui.core.routing.HashChanger#replaceHash is called
Parameters:
{sap.ui.base.Event}oEvent
{sap.ui.base.EventProvider}oEvent.getSource
{object}oEvent.getParameters
{string}oEvent.getParameters.sHash The URL hash
hashSet(oEvent)
The 'hashSet' event is fired when sap.ui.core.routing.HashChanger#setHash is called
Parameters:
{sap.ui.base.Event}oEvent
{sap.ui.base.EventProvider}oEvent.getSource
{object}oEvent.getParameters
{string}oEvent.getParameters.sHash The URL hash
Method Detail
sap.ui.core.routing.HashChanger.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.core.routing.HashChanger with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.base.EventProvider.extend.

Parameters:
{string}sClassName Name of the class being created
{object}oClassInfo? Object literal with information about the class
{function}FNMetaImpl? Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
{function} Created class / constructor function
sap.ui.core.routing.HashChanger.getInstance()
Gets a global singleton of the HashChanger. The singleton will get created when this function is invoked for the first time.
sap.ui.core.routing.HashChanger.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.core.routing.HashChanger.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
sap.ui.core.routing.HashChanger.replaceHashChanger(oHashChanger)
Sets the hashChanger to a new instance, destroys the old one and copies all its event listeners to the new one
Parameters:
{sap.ui.core.routing.HashChanger}oHashChanger the new instance for the global singleton
destroy()
Cleans the event registration
See:
sap.ui.base.Object.prototype.destroy
fireHashChanged(newHash, oldHash)
Fires the hashchanged event, may be extended to modify the hash before fireing the event
Parameters:
{string}newHash the new hash of the browser
{string}oldHash the previous hash
getHash(): string
Gets the current hash
Returns:
{string} the current hash
init()
Will start listening to hashChanges with the parseHash function. This will also fire a hashchanged event with the initial hash.
replaceHash(sHash)
Replaces the hash to a certain value. When using the replace function no browser history is written. If you want to have an entry in the browser history, please use set setHash function.
Parameters:
{string}sHash the hash
setHash(sHash)
Sets the hash to a certain value. When using the set function a browser history entry is written. If you do not want to have an entry in the browser history, please use set replaceHash function.
Parameters:
{string}sHash the hash