Class sap.m.routing.RouterModule: sap/m/routing/Router

extends Router


Since: 1.28.1.
Constructor Summary
new sap.m.routing.Router(oRoutes?, oConfig?, oOwner?, oTargetsConfig?)Instantiates a SAPUI5 mobile Router see sap.ui.core.routing.Router for the constructor arguments The difference to the sap.ui.core.routing.Router are the properties viewLevel, transition and transitionParameters you can specify in every Route or Target created by this router.
Method Summary
sap.m.routing.Router.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.m.routing.Router with name sClassName and enriches it with the information contained in oClassInfo.
sap.m.routing.Router.getMetadata()Returns a metadata object for class sap.m.routing.Router.
getTargetHandler()Returns the TargetHandler instance.
Methods borrowed from class sap.ui.base.Object
Constructor Detail
new sap.m.routing.Router(oRoutes?, oConfig?, oOwner?, oTargetsConfig?)
Instantiates a SAPUI5 mobile Router see sap.ui.core.routing.Router for the constructor arguments The difference to the sap.ui.core.routing.Router are the properties viewLevel, transition and transitionParameters you can specify in every Route or Target created by this router.
Parameters:
{object|object[]}oRoutes? may contain many Route configurations as sap.ui.core.routing.Route.
Each of the routes contained in the array/object will be added to the router.

One way of defining routes is an array:

[
    //Will create a route called 'firstRouter' you can later use this name in navTo to navigate to this route
    {
        name: "firstRoute"
        pattern : "usefulPattern"
    },
    //Will create a route called 'anotherRoute'
    {
        name: "anotherRoute"
        pattern : "anotherPattern"
    }
]

The alternative way of defining routes is an Object.
If you choose this way, the name attribute is the name of the property.

{
    //Will create a route called 'firstRouter' you can later use this name in navTo to navigate to this route
    firstRoute : {
        pattern : "usefulPattern"
    },
    //Will create a route called 'anotherRoute'
    anotherRoute : {
        pattern : "anotherPattern"
    }
}
The values that may be provided are the same as in sap.ui.core.routing.Route
{object}oConfig? Default values for route configuration - also takes the same parameters as sap.ui.core.routing.Target.
This config will be used for routes and for targets, used in the router
Eg: if the config object specifies :

{ viewType : "XML" }

The targets look like this:
{
    xmlTarget : {
        ...
    },
    jsTarget : {
        viewType : "JS"
        ...
    }
}
Then the effective config will look like this:
{
    xmlTarget : {
        viewType : "XML"
        ...
    },
    jsTarget : {
        viewType : "JS"
        ...
    }
}

Since the xmlTarget does not specify its viewType, XML is taken from the config object. The jsTarget is specifying it, so the viewType will be JS.

{string|string[]}oConfig.bypassed.target? One or multiple names of targets that will be displayed, if no route of the router is matched.
A typical use case is a not found page.
The current hash will be passed to the display event of the target.
Example:

    new Router(
    // Routes
    [
        // Any route here
    ],
    {
        bypassed: {
            // you will find this name in the target config
            target: "notFound"
        }
    },
    // You should only use this constructor when you are not using a router with a component. Please use the metadata of a component to define your routes and targets. The documentation can be found here: sap.ui.core.UIComponent#.extend.
    null,
    // Target config
    {
         //same name as in the config.bypassed.target
         notFound: {
             viewName: "notFound",
             ...
             // more properties to place the view in the correct container
         }
    });

{boolean}oConfig.async? @since 1.34. Whether the views which are loaded within this router instance asyncly. The default value is set to false.
{sap.ui.core.UIComponent}oOwner? the Component of all the views that will be created by this Router,
will get forwarded to the sap.ui.core.routing.Views#contructor.
If you are using the componentMetadata to define your routes you should skip this parameter.
{object}oTargetsConfig? the target configuration, see sap.m.routing.Targets documentation (the options object).
You should use Targets to create and display views. The route should only contain routing relevant properties.
Example:

    new Router(
    // Routes
    [
        {
            // no view creation related properties are in the route
            name: "startRoute",
            //no hash
            pattern: "",
            // you can find this target in the targetConfig
            target: "welcome"
        }
    ],
    // Default values shared by routes and Targets
    {
        viewNamespace: "my.application.namespace",
        viewType: "XML"
    },
    // You should only use this constructor when you are not using a router with a component.
    // Please use the metadata of a component to define your routes and targets.
    // The documentation can be found here: sap.ui.core.UIComponent#.extend.
    null,
    // Target config
    {
         //same name as in the route called 'startRoute'
         welcome: {
             // All properties for creating and placing a view go here or in the config
             viewName: "Welcome",
             controlId: "app",
             controlAggregation: "pages"
         }
    })

Method Detail
sap.m.routing.Router.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.m.routing.Router 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.core.routing.Router.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.m.routing.Router.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.routing.Router.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
getTargetHandler(): sap.m.routing.TargetHandler
Returns the TargetHandler instance.
Returns:
{sap.m.routing.TargetHandler} the TargetHandler instance