on 04-22-2016 10:24 AM
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?
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"
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
}
}
}
}
}
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 | |||||
} | |||||
} |
In target also pass it as page2
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please share the code inside your view, controller and Component.js
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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() {
}
}
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.