<!DOCTYPE html>
<html style="height: 100%;">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<title>Demo</title>
<script
id="sap-ui-bootstrap"
src="https://sdk.openui5.org/resources/sap-ui-core.js"
data-sap-ui-libs="sap.ui.core,sap.m"
data-sap-ui-theme="sap_horizon_dark"
data-sap-ui-async="true"
data-sap-ui-compatversion="edge"
data-sap-ui-modules="demo/shared/onButtonPress"
data-sap-ui-excludejquerycompat="true"
data-sap-ui-resourceroots='{"demo": "./"}'
data-sap-ui-xx-waitfortheme="init"
></script>
<script>{
sap.ui.getCore().attachInit(() => sap.ui.require([
"sap/ui/core/mvc/XMLView",
], async XMLView => (await Promise.all([
XMLView.create({ definition: defineView("First") }),
XMLView.create({ definition: defineView("Second") }),
])).map(view => view.placeAt("content"))));
function defineView(controllerName) {
return `<mvc:View controllerName="demo.controller.${controllerName}"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
xmlns:core="sap.ui.core"
core:require="{ onButtonPress: 'demo/shared/onButtonPress' }">
<Panel headerText="${controllerName} View">
<Button text="Press" press="onButtonPress" />
</Panel>
</mvc:View>`;
} // See OpenUI5 documentation topic "Handling Events in XML Views".
}</script>
</head>
<body id="content" class="sapUiBody"></body>
</html>
sap.ui.define([
"sap/m/MessageToast",
], function(MessageToast) {
"use strict";
return function(event) {
const control = event.getSource();
const message = `${control} pressed from ${this.getMetadata().getName()}`;
MessageToast.show(message);
};
});
sap.ui.define([
"sap/ui/core/mvc/Controller",
], function(Controller) {
"use strict";
return Controller.extend("demo.controller.First", {
// Nothing to see here.
// Button press is handled in ./shared/eventHandler.js
});
});
sap.ui.define([
"sap/ui/core/mvc/Controller",
], function(Controller) {
"use strict";
return Controller.extend("demo.controller.Second", {
// Nothing to see here.
// Button press is handled in ./shared/eventHandler.js
});
});