cancel
Showing results for 
Search instead for 
Did you mean: 

UIComponent.js:6 Uncaught Error: No view type specified.

former_member197888
Participant
0 Kudos

I have mad an Fiori application and There are 2 pages in that application. On page1 there is a button . On press event of that button it would navigate to page 2.

My index.html is as follows:-

<!DOCTYPE HTML>

<html>

  <head>

  <meta http-equiv="X-UA-Compatible" content="IE=edge" />

  <meta charset="UTF-8">

  <title>StartApplication</title>

  <script id="sap-ui-bootstrap"

  src="../../resources/sap-ui-core.js"

  data-sap-ui-libs="sap.m"

  data-sap-ui-theme="sap_bluecrystal"

  data-sap-ui-compatVersion="edge"

  data-sap-ui-resourceroots='{"QuickStartApplication": "./"}'>

  </script>

  <link rel="stylesheet" type="text/css" href="css/style.css">

  <script>

  sap.ui.getCore().attachInit(function() {

  new sap.m.Shell({

  app: new sap.ui.core.ComponentContainer({

  height : "100%",

  name : "StartApplication"

  })

  }).placeAt("content");

  });

  </script>

  </head>

And my manifest.json includes the code for routing after which this error has appear:-

{

  "_version": "1.1.0",

  "sap.app": {

  "_version": "1.1.0",

  "id": "StartApplication",

  "type": "application",

  "i18n": "i18n/i18n.properties",

  "applicationVersion": {

  "version": "1.0.0"

  },

  "title": "{{DemoApp}}",

  "resources": "resources.json",

  "ach": "ach",

  "sourceTemplate": {

  "id": "servicecatalog.connectivityComponent",

  "version": "0.0.0"

  },

  "dataSources": {

  "mainService": {

  "type": "OData",

  "settings": {

  "odataVersion": "2.0",

  "localUri": "localService/metadata.xml"

  },

  "uri": "localService/metadata.xml"

  }

  }

  },

  "sap.ui": {

  "_version": "1.1.0",

  "technology": "UI5",

  "icons": {

  "icon": "",

  "favIcon": "",

  "phone": "",

  "phone@2": "",

  "tablet": "",

  "tablet@2": ""

  },

  "deviceTypes": {

  "desktop": true,

  "tablet": true,

  "phone": true

  },

  "supportedThemes": ["sap_hcb", "sap_bluecrystal"]

  },

  "sap.ui5": {

  "_version": "1.1.0",

  "rootView": {

  "viewName": "StartApplication.view.App",

  "type": "XML"

  },

  "dependencies": {

  "minUI5Version": "1.30.0",

  "libs": {

  "sap.ui.core": {},

  "sap.m": {},

  "sap.ui.layout": {}

  }

  },

  "contentDensities": {

  "compact": true,

  "cozy": true

  },

  "models": {

  "i18n": {

  "type": "sap.ui.model.resource.ResourceModel",

  "settings": {

  "bundleName": "StartApplication.i18n.i18n"

  }

  },

  "": {

  "dataSource": "mainService"

  }

  },

  "resources": {

  "css": [{

  "uri": "css/style.css"

  }]

  },

  "routing": {

  "config": {

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

  "viewPath": "StartApplication.view",

  "controlId": "app",

  "controlAggregation": "pages",

  "transition" : "slide"

  },

  "routes": [{

  "pattern": "",

     "name" : "view1",

  "target": "view1"

  },

  {

    "pattern": "pge2",

     "name" : "page2",

  "target": "pge2"

  }],

  "targets": {

  "view1": {

  "viewName": "View1",

  "viewLevel" : 1

  },

  "page2": {

  "viewName": "Pge2",

  "viewLevel" : 2

  }

  }

  }

  }

}

Can anyone help me to resolve this issue?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Can you please add the viewtype to your manifest.json as shown below and try again.

"config": {

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

     "viewType": "XML",

  "viewPath": "StartApplication.view",

  "controlId": "app",

  "controlAggregation": "pages",

  "transition" : "slide"

  },

former_member197888
Participant
0 Kudos

I tried this and now this error is gone but now I am getting another error :-

Can please help me with this ?

Former Member
0 Kudos

Inside your View1 controller, please add this function and try again.

getRouter : function () {
return sap.ui.core.UIComponent.getRouterFor(this);
},

former_member197888
Participant
0 Kudos

Error is gone but it still didn't navigate to page 2 of the application.

I am getting this error :-

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

Former Member
0 Kudos

In your manifest.json, you have given name target as "pge2". but in targets you have named it as "page2". Can you please keep both as page2 and try agian.

  "routes": [{

  "pattern": "",

     "name" : "view1",

  "target": "view1"

  },

  {

    "pattern": "pge2",

     "name" : "page2",

  "target": "pge2"

  }],

  "targets": {

  "view1": {

  "viewName": "View1",

  "viewLevel" : 1

  },

  "page2": {

  "viewName": "Pge2",

  "viewLevel" : 2

  }

  }

  }

  }

}

former_member197888
Participant
0 Kudos

Yes I did that but still the same error is there.

Now my code for manifest.json is as follows:-

"routes": [{
"name": "view1",
"pattern": "",
"greedy": false,
"target": ["view1"]
}, {
"name": "page2",
"pattern": "",
"greedy": false,
"target": ["page2"]
}],
"targets": {
"view1": {
"viewName": "View1",
"viewLevel": 1
},
"page2": {
"viewName": "Pge2",
"viewLevel": 2
}
}

Answers (3)

Answers (3)

Former Member
0 Kudos

In target also pass it as page2

former_member197888
Participant
0 Kudos

Yes I did pass the value as page2 only as you can see above I have pasted the modified manifest.json code .

Former Member
0 Kudos

change it to below and try again

"routes": [

{

"name": "view1",

"pattern": "",

"greedy": false,

"target": "view1"

},

{

"name": "page2",

"pattern": "",

"greedy": false,

"target": "page2"

}

],

"targets": {

"view1": {

"viewName": "View1",

"viewLevel": 1

},

"page2": {

"viewName": "Pge2",

"viewLevel": 2

}

}

Former Member
0 Kudos

Click: function () {

//This code was generated by the layout editor.

//this.navTo("");

this.getRouter().navTo("page2");

  }

here you are using "page2" but you have not given that id to to your page 2

former_member197888
Participant
0 Kudos

In manifest.json I have given that name page2 . So that's why I am using it.

Former Member
0 Kudos

Please share the code inside your view, controller and Component.js

former_member197888
Participant
0 Kudos

Code inside my View is as follows:-

My First View Page:-  View1.view.xml

<mvc:View xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="StartApplication.controller.View1">

  <Page title="Welcome to First Page" id="idpage1">

  <content>

  <Button text="Click me!!" press="Click" busy="false" type="Accept"/>

  </content>

  </Page>

</mvc:View>


Code of my Second View:-  Pge2.view.xml

<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="StartApplication.controller.Pge2"

  xmlns:html="http://www.w3.org/1999/xhtml">

  <Page title="Welcome to Page2">

  <content>

     <Text text=" Navigation successful.."></Text>

  </content>

  </Page>

</mvc:View>

Code of my Controllers:-

My first controller :- View1.controller.js

sap.ui.define(["sap/ui/core/mvc/Controller"], function (Controller) {

  "use strict";

  return Controller.extend("StartApplication.controller.View1", {

  /**

  *@memberOf QuickStartApplication.controller.View1

  */

Click: function () {

//This code was generated by the layout editor.

//this.navTo("");

this.getRouter().navTo("page2");

  }

  });

});

Note:-  I have added any code inside Pge2.controller.js

Code inside Component.js:-

sap.ui.define([

  "sap/ui/core/UIComponent",

  "sap/ui/Device",

  "StartApplication/model/models"

], function(UIComponent, Device, models) {

  "use strict";

  return UIComponent.extend("StartApplication.Component", {

  metadata: {

  manifest: "json"

  },

  /**

  * The component is initialized by UI5 automatically during the startup of the app and calls the init method once.

  * @public

  * @override

  */

  init: function() {

  // call the base component's init function

  UIComponent.prototype.init.apply(this, arguments);

            this.getRouter().initialize();

  // set the device model

  this.setModel(models.createDeviceModel(), "device");

  }

  });

});

And I have made one more view with app control in it and its code is as follows(App.view.xml) :-

<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="StartApplication.controller.App"

  xmlns:html="http://www.w3.org/1999/xhtml" displayBlock="true">

  <App id="app"/>

</mvc:View>

And its Controller's code is as follows(App.controller.js) :-

sap.ui.define([

  "sap/ui/core/mvc/Controller"

], function(Controller) {

  "use strict";

  return Controller.extend("StartApplication.controller.App", {

onInit: function() {

  }

}

former_member225463
Participant
0 Kudos

Hello Manali,

you have declared your resource roots as :

data-sap-ui-resourceroots='{"QuickStartApplication": "./"}'>


but in your view the path is "viewName": "StartApplication.view.App",


change it from StartApplication to QuickStartApplication and check.


Regards,

Vikash

former_member197888
Participant
0 Kudos

Yes I have already done that also but still the same error is there.