0
votes

im using in my app the sap.ui.core.routing.Router, and the routing works fine in the app and by changing the url to a valid route. But if i provide an invalid route in the url the application shows an empty "page". Im want to have a fallback, in order the route cant be found it should navigate to the welcome page.

here is a part of my component.js

routing : {
            config : {
                routerClass : "com.some.namespace.Router",
                viewType : "JSON",
                viewPath : "com.some.namespace.views",
                controlId : "RoutingControl",
                controlAggregation : "contentOfRoutingControl",
                clearTarget : true
            },
            routes : [
                {
                    pattern : "",
                    name : "firstRoute",
                    view : "first"
                },
                {
                    pattern : "Connector",
                    name : "conRoute",
                    view : "Connector"
                },
...
1

1 Answers

0
votes

i figured it out by myself. I provide an array as patten for the default route, with the "catchall" phrase :all*: and provided that route as the last route

routing : {
        config : {
            routerClass : "com.some.namespace.Router",
            viewType : "JSON",
            viewPath : "com.some.namespace.views",
            controlId : "RoutingControl",
            controlAggregation : "contentOfRoutingControl",
            clearTarget : true
        },
        routes : [                
            {
                pattern : "Connector",
                name : "conRoute",
                view : "Connector"
            },
...
            {
                pattern : ["", ":all*:"],
                name : "firstRoute",
                view : "first"
            }
       ]

...