我想創建一個定製的SAP啓動板。爲此,我需要使用sap.ui.unified.Shell
作爲容器。可以在該shell的內容中加載一些oControlls。現在我的問題是如何在這個shell容器中使用路由並加載這個shell的其他視圖?或者,也許我怎麼才能連接SAP路由器加載數據在殼集裝箱內?如何瀏覽sap.ui.unified.Shell內部?
回答
Here是有關如何加載不同視圖統一殼內部的很好的例子:
的index.html:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">
<title>Column Micro Chart on a Generic Tile</title>
<script id="sap-ui-bootstrap"
src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-libs="sap.m"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-preload="async"
data-sap-ui-compatVersion="edge"
data-sap-ui-resourceroots='{
"Testing": "./"
}'>
</script>
<!-- Application launch configuration -->
<script>
sap.ui.getCore().attachInit(function() {
new sap.ui.core.ComponentContainer({
height : "100%",
name : "Testing"
}).placeAt("content");
});
</script>
</head>
<!-- UI Content -->
<body class="sapUiBody" id="content" role="application">
</body>
</html>
Component.js
sap.ui.define(['sap/ui/core/UIComponent'],
function(UIComponent) {
"use strict";
var Component = sap.ui.core.UIComponent.extend("Testing.Component", {
metadata: {
rootView: "Testing.view.App",
dependencies: {
libs: [
"sap.m",
"sap.suite.ui.microchart"
]
},
config: {
sample: {
files: [
"view/App.view.xml",
"controller/App.controller.js"
]
}
},
routing: {
config: {
viewType: "XML",
viewPath: "Testing.view",
controlId: "appShell",
clearTarget: true,
routerClass: "sap.ui.core.routing.Router"
},
routes: [{
pattern: "",
name: "home",
target: "home"
},
{
pattern: "routed",
name: "routed",
target: "routed"
}
],
targets: {
home: {
viewName: "Home",
controlId: "appShell",
controlAggregation: "content",
clearAggregation: true
},
routed: {
viewName: "Routed",
controlId: "appShell",
controlAggregation: "content",
clearAggregation: true
}
}
}
},
init: function() {
// call the init function of the parent
UIComponent.prototype.init.apply(this, arguments);
// this component should automatically initialize the router
this.getRouter().initialize();
}
});
return Component;
});
控制器/應用程序。 controller.js
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function(Controller) {
"use strict";
return Controller.extend("Testing.controller.App", {
onInit: function() {
}
});
});
控制器/ Home.controller.js
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function(Controller) {
"use strict";
return Controller.extend("Testing.controller.Home", {
onInit: function() {
},
onButtonPress: function (oEvent) {
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
this.getView().getParent().removeAllContent();
oRouter.navTo("routed", false);
}
});
});
控制器/ Routed.controller.js
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function(Controller) {
"use strict";
return Controller.extend("Testing.controller.Routed", {
onInit: function() {
},
onButtonPress: function (oEvent) {
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
this.getView().getParent().removeAllContent();
oRouter.navTo("home", false);
}
});
});
視圖/ App.view.xml
<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
xmlns:u="sap.ui.unified" controllerName="Testing.controller.App" displayBlock="true">
<u:Shell id="appShell">
<u:headItems>
<u:ShellHeadItem tooltip="Configuration" icon="sap-icon://menu2"
press="handlePressConfiguration" />
<u:ShellHeadItem tooltip="Home" icon="sap-icon://home"
press="handlePressHome" />
</u:headItems>
<u:user>
<u:ShellHeadUserItem image="sap-icon://person-placeholder"
username="{shell>/userName}" />
</u:user>
<u:paneContent>
</u:paneContent>
<u:content>
</u:content>
</u:Shell>
</mvc:View>
視圖/ Home.view。 xml
<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
controllerName="Testing.controller.Home" displayBlock="true">
<Page title="Home">
<headerContent>
<Button text="to route" press="onButtonPress" />
</headerContent>
<content>
</content>
</Page>
</mvc:View>
查看/ Routed.view.xml
<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
controllerName="Testing.controller.Routed" displayBlock="true">
<Page title="A route">
<headerContent>
<Button text="to home" press="onButtonPress" />
</headerContent>
<content>
</content>
</Page>
</mvc:View>
親愛的Martin,您的回答幾乎是正確的,但問題在於頁面內容沒有顯示在shell內部。 –
只需刪除頁面標籤並直接在視圖標籤中插入元素,而不是在頁面內容中插入元素。 – 2017-02-14 13:40:01
我不會編輯答案,因爲可能發生其他人面臨此問題。 – 2017-02-14 13:40:58
- 1. 瀏覽器內部的瀏覽器
- 2. 如何禁用aptana內部瀏覽器
- 3. 如何瀏覽WebView內部的外部網頁
- 4. 清除Eclipse的內部Web瀏覽器
- 5. Web瀏覽器內部構件
- 6. 終端/控制檯內部瀏覽器
- 7. Objective C語法 - 內部瀏覽器
- 8. 瀏覽器內部的URL編碼
- 9. 循環瀏覽內部文章xpath
- 10. Web瀏覽器內部控制IE
- 11. 如何設置瀏覽器內部窗口/視口大小?
- 12. 如何檢測瀏覽器內部JavaScript錯誤?
- 13. 如何設置內部瀏覽器的Aptana在Linux上
- 14. 如何檢測移動設備的瀏覽器內部寬度
- 15. vb.net如何從網頁瀏覽器獲取此內部文本
- 16. Chromedriver如何在瀏覽器內部進行通信?
- 17. 事情是如何嵌入瀏覽器內部的?
- 18. 瀏覽器與端口通信如何在內部工作
- 19. 如何從JavaScript內部打開新的瀏覽器選項卡?
- 20. 如何啓用eclipse內部瀏覽器(Ubuntu 12.10)?
- 21. 瀏覽器內的瀏覽器
- 22. 瀏覽器內聊天如何工作?
- 23. 如何瀏覽彈出框內的UITableView
- 24. 如何瀏覽DLL文件的內容
- 25. 如何使用javascript瀏覽json內容?
- 26. 如何瀏覽字段集內的表
- 27. 如何禁用瀏覽器瀏覽器?
- 28. 如何通過單擊照片瀏覽android的內部和外部存儲(sdcard)?
- 29. 如何在eclipse中的外部瀏覽器而不是內部調試PHP?
- 30. 如何打開瀏覽器中的外部URL和Webview中的內部URL
請注意,sap.ui.unified.Shell是標誌着自棄用版本1.44.0 – matbtt
那麼什麼是SAP本身使用,用於創建標準啓動板?我想爲自己創建一個自定義啓動板。 –
我需要的東西像sap.ui.unified.Shell有一個容器部分,我可以加載不同的視圖,但具有相同的標題,看起來像標準啓動板。 –