Last active
September 8, 2023 12:01
-
-
Save se38/8322054 to your computer and use it in GitHub Desktop.
Binding problems with UI5 and XML views
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<script src="resources/sap-ui-core.js" | |
id="sap-ui-bootstrap" | |
data-sap-ui-libs="sap.m" | |
data-sap-ui-theme="sap_bluecrystal"> | |
</script> | |
<script> | |
sap.ui.localResources("ui5test"); | |
var app = new sap.m.App({initialPage:"idstart1"}); | |
var page = sap.ui.view({id:"idstart1", viewName:"ui5test.start", type:sap.ui.core.mvc.ViewType.XML}); | |
app.addPage(page); | |
app.placeAt("content"); | |
</script> | |
</head> | |
<body class="sapUiBody"> | |
<div id="content"></div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sap.ui.controller("ui5test.start", { | |
onInit: function() { | |
var oModel = new sap.ui.model.json.JSONModel( | |
{ | |
"value1": "Doesn't work", | |
"value2" : "Does work" | |
}); | |
sap.ui.getCore().setModel(oModel); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" | |
controllerName="ui5test.start" xmlns:html="http://www.w3.org/1999/xhtml"> | |
<Page title="Title"> | |
<content> | |
<Input | |
id="idInput1" | |
type="Text" | |
value="{ | |
path : '/value1', | |
type : 'sap.ui.model.type.String', | |
constraints : { | |
minLength: 1, | |
maxLength: 10 | |
} | |
}" /> | |
<Input | |
id="idInput2" | |
type="Text" | |
value="{/value2}" /> | |
<Text text="{ path : '/value1'}" /> | |
<Text text="{/value2}" /> | |
</content> | |
</Page> | |
</core:View> |
Hi Uwe,
I had the same problem.
The solution is to use data-sap-ui-xx-bindingSyntax="complex" in your bootstrap tag in index.html to activate the complex binding syntax in XML views. More info: https://sapui5.hana.ondemand.com/sdk/#docs/guide/91f37e746f4d1014b6dd926db0e91070.html
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi!
Is there anyway to build the sap ui control with a dynamic ID ? (Using XML view)
Like:
Regards