on 2014 Feb 04 9:40 AM
I am trying to run this example but some how just cant
<!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.ui.commons"
data-sap-ui-theme="sap_goldreflection">
</script>
<!-- add sap.ui.table,sap.ui.ux3 and/or other libraries to 'data-sap-ui-libs' if required -->
<script>
$(document).ready(function()
{
var data =
{
company:
{
properties: [
{value: "Hello"},
{value: true},
{value: 45},
]
}
}
var oModel = sap.ui.model.json.JSONModel();
oModel.setData(data);
sap.ui.getCore().setModel(oModel);
var oContainer = new sap.ui.core.ComponentContainer("oContainer", {
name: "oContainer",
settings: {text: "Hello World 2"}
});
alert("...");
oContainer.bindAggregation("content", "/company/properties", function(sId, oContext)
{
var value = oContext.getProperty("value");
switch(typeof value)
{
case "string":
return new sap.ui.commons.TextField(sId, {
value: {
path: "value",
//type: new sap.ui.model.type.String();
}
});
case "number":
return new sap.ui.commons.TextField(sId, {
value: {
path: "value",
// type: new sap.ui.model.type.Float();
}
});
case "boolean":
return new sap.ui.commons.CheckBox(sId, {
checked: {
path: "value"
}
});
}
});
});
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>
After some debug via fireBug, I saw it threw errors with code lines that look like:
type: new sap.ui.model.type.
So I commented them out..
However theres another error now that says:
Aggregation "content" does not exist in Element sap.ui.core.ComponentContainer#oContainer
Whats it that I am doing wrong here...
Thanks for all your help ...
Amjad
Request clarification before answering.
Hi,
The ComponentContainer doesn't provide a 'content aggregation', so you can't bind the content in this manner.
https://sapui5.hana.ondemand.com/sdk/#docs/api/symbols/sap.ui.core.ComponentContainer.html
You also don't need to define the data in the jQuery ready block.
Regards,
Jason
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your answer Jason, i appreciate it..
However I picked this example from the Developer guide here SAPUI5 SDK - Demo Kit
Theres a snippet of code there that shows how bindAggregation could be accomplished using factory methods...
I can remove the code from the ready function though..
Please tell me how could binAggregation be done with factory methods if this example is incorrect..
Thanks a ton in advance for responding...
| User | Count |
|---|---|
| 9 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.