cancel
Showing results for 
Search instead for 
Did you mean: 

VM2938 Router.js:6 Uncaught TypeError: Cannot read property 'setHash' of undefined

former_member197888
Participant
0 Kudos

I have made a Fiori application where in there are 2 pages . On the first page's button click it would navigate to page 2 . But when I click on the button I  am getting an error Cannot read property 'setHash' of Undefined.

Below is the code of my manifest.json for routing :-

"routing": {

        "targets": {

            "view1": {

                "viewName": "View1",

                "viewId": "V1",

                "viewLevel": 1

            },

            "page2": {

                "viewName": "Pge2",

                "viewId": "V2",

                "viewLevel": 2

            }

        },

       

         "config": {

            "routerClass": "sap.m.routing.Router",

            "targetsClass": "sap.m.routing.Targets",

            "viewType": "XML",

            "viewPath": "QuickStartApplication.view",

            "controlId": "app",

            "controlAggregation": "pages",

            "targetParent": "Page",

            "transition": "slide",

            "clearAggregation": false

        },

        "routes": [{

            "name": "view1",

            "pattern": "",

            "greedy": false,

            "target": ["View1"]

        }, {

            "name": "page2",

            "pattern": "next",

            "greedy": false,

            "target": ["Pge2"]

        }]

Can anyone help me with this?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Hi Manali,

I had the same problem. My project was started form a template in WebIDE .

In my case the solution was:

  1. Check your manifest.json
  2. Check what view is assigned there as root view under "sap.ui5": { "rootView":
  3. Go to the view XML of that view (I was using XML views)
  4. Check if that contains an App tag, and if the tag has an ID like
    <App id="app">
  5. Go back to the manifest.json, and check the router configuration, controllId should point to the same id: "routing": { "config": { "controlId": "app",
  6. Finally, from the Component.js had to initialize the router this.getRouter().initialize();

Then sap.ui.core.UIComponent.getRouterFor(this).navTo(... worked fine.

Hope that helps.

Gabor

former_member197888
Participant
0 Kudos

Thanks Gabor

It worked.

Former Member
0 Kudos

Hello, Manali! I have same problem. (

Could you give description how did you resolve this problem? Maybe attach your files?

former_member197888
Participant
0 Kudos

Hi Evgeny,

I just followed the above steps mentioned by Gabor and it worked for me .

1. Firstly check that the view mentioned in rootView has a control App 

for example , <App id="app>

                    ...

                    ...

                     </App>

I my app first page is named as View1. So its configuration in manifest.json is as shown above .

Then in manifest.json check :-  "routing": { "config": { "controlId": "app",

Besides this also check the routes are defined correctly or not .

Also be sure that in Component.js you have initialized the router and  also check if in the contoller you have written the getRouter function.

And if you could tell which file you want to see I can provide that file.

Hope it helps.

Former Member
0 Kudos

Could do you create your project and export it?

former_member197888
Participant
0 Kudos

Yes I am able export my project .

Former Member
0 Kudos

I opened for show my gmail in my profile. Please, send me your project ).

former_member197888
Participant
0 Kudos

ok .

Former Member
0 Kudos

thanks, it is work!

Answers (0)