Show TOC

Configuration Parameters for NavigationLocate this document in the navigation structure

For navigation, configuration parameters for the route and the router have to be provided.

The router supports the following three parameters:

  • routes

    The routes parameter defines an array of route configurations.

  • config

    The config parameter defines the default values for route configuration.

  • owner

    The owner parameter defines the owner of all views that are created by the router. This is typically a UIComponent.

The router configuration does support all the values a route support. If a route does not provide a value, the value of the router configuration will be taken.

"routing" : {
    // The default values for every route
    "config" : {
        "viewType" : "XML",
        "viewPath" : "MyApp.view",
    },
    // The route configurations
    "routes" : {
        "myRoute" : {
            "viewType" : "JS",
        "pattern" : "foo",
        }
    }
}

Routes are used to notify the application if the hash changed to a certain value. When a route matches the hash, it provides the data passed over the hash to a defined handler. For route configuration, SAPUI5 provides the parameters:

  • name

    The route name parameter identifies the route and has to be unique within one router instance.

  • pattern

    The pattern parameter defines the string that is matched against the hash. Only the first route with a matching pattern triggers the callback.

  • view

    The view parameter contains the name of the view that is created on the first time a route is matched. To place the view in a control, use targetAggregation and targetControl. Views are only created once.

  • viewType

    The view type parameter defines the view type that is created.

  • viewPath

    The view path parameter specifies a prefix that prepends the view; if, for example, view is set to "myView" and viewPath is set to "myApp", the created view is myApp.myView.

  • targetParent

    The target parent parameter defines the ID of the parent of the targetControl parameter.

  • targetControl

    Views are put into a container control, for example a shell control or a NavContainer for mobile applications, or into any other container. The targetControl parameter contains the ID of this control.

  • targetAggregation

    The target application parameter contains the name of an aggregation of the target control that contains views. A NavContainer, for example, has an aggregation called Pages and the shell container has Content.

  • clearTarget

    The clear target parameter defines a boolean that is used to specify if the aggregation should be cleared before adding the view to it.

  • subroutes

    The subroutes parameter contains an array of routes and can contain the complete route configuration. Routes that are added to subroutes may have subroutes themselves.

  • callback

    The callback parameter is an optional function that is executed after the route has matched.

metadata: {
    routing: {
        config: {
            viewType: "XML",
            viewPath: "view",
            targetControl: "splitApp",
            clearTarget: false,
            },
        routes: [
            {
            pattern: "category/{id}",
            name: "category",
            view: "Category",
            targetAggregation: "masterPages",
            subroutes: [
                {
                pattern: "category/{id}/product/{productId}",
                name: "product",
                view: "Product",
                targetAggregation: "detailPages"
                }
            ]
            },
            {
            pattern: "",
            name : "home",
            view : "Home",
            targetAggregation : "masterPages",
            subroutes : [
                {
                pattern : "{all*}",
                name : "notFound",
                view : "notFound",
                targetAggregation : "detailPages"
                }
                ]
            }
            ]
        }