Sap-ui5-views
提供:Dev Guides
SAP UI5-ビュー
ビューは、次のようにSAPライブラリを使用して定義されます-
- HTML、混合、またはスタンドアロンのXML:Library- sap.ui.core.mvc.XMLView
- JavaScript:ライブラリ-sap.ui.core.mvc.JSView
- JSON:ライブラリ-sap.ui.core.mvc.JSONView
- HTML:ライブラリ-sap.ui.core.mvc.HTMLView
JavaScriptのサンプルを表示
Sap.ui.jsview(“sap.hcm.address”, {
getControllerName: function() {
return “sap.hcm.address”;
},
createContent: function(oController) {
var oButton = new sap.ui.commons.Button({ text: “Hello” });
oButton.attachPress(function() {
oController.Hello();
})
Return oButton;
}
});
HTMLビューのサンプル
<template data-controller-name = ”sap.hcm.address’>
<h1>title</h1>
<div> Embedded html </div>
<div class = ”test” data-sap-ui-type = ”sap.ui.commons.Button”
Id = ”Button1” data-text = ”Hello” Data-press = ”sayHello”>
</div>
</template>
同様に、sap.ui.core.mvc.JsonViewから派生したJSONビューを作成できます。
{
“type”:”sap.ui.core.mvc.JsonView”,
“controllerName”:”sap.hcm.address”,
……………………….
…………………...
…………………….
}
ビュータイプの比較
次の表に、MVCの概念に関連する主要な機能と、機能と異なるビュータイプの比較を示します。
Feature | JS View | XML View | JSON View | HTML View |
---|---|---|---|---|
Standard and Custom Libraries | Yes | Yes | Yes | Yes |
Properties of types string, int Boolean, float | Yes | Yes | Yes | Yes |
Aggregation 1:1, 1:n Association 1:1, 1:n | Yes | Yes | Yes | Yes |
Simple Data Binding | Yes | Yes | Yes | Yes |
Customize Data Binding | Yes | No | No | No |
Embedded HTML | No | Yes | No | No |
Code Completion | Yes | Yes | No | No |
Templating | Yes | No | No | No |
Validation | No | Yes | No | No |
Single Event Listener | Yes | Yes | Yes | Yes |