ManagedObject: "objectBindings" support in XML view / fragment definitions
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 3.3k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
URL (minimal example if possible)
https://jsbin.com/hopizef/edit?html,js,output
Given
<MyControl objectBindings="{
myModel: { path: '/someObject' },
myAnotherModel: { path: '/objectFromAnotherModel' }
}" />
What is the expected result?
ManagedObject calls bindObject according to the API contract for each key without any issues.
https://github.com/SAP/openui5/blob/ca82db0229de26dec2fc554353838ad8e6fc5401/src/sap.ui.core/src/sap/ui/base/ManagedObject.js#L1150-L1153
What happens instead?
The only place in the XMlTemplateProcessor, where objectBindings is handled, is this one:
https://github.com/SAP/openui5/blob/ca82db0229de26dec2fc554353838ad8e6fc5401/src/sap.ui.core/src/sap/ui/core/XMLTemplateProcessor.js#L803-L809
But that results in the following objectBindings object:
{ undefined: { myAnotherModel: { path: "/objectFromAnotherModel" }, myModel: { path: "/someObject" } } }
which is passed to ManagedObject settings:
https://github.com/SAP/openui5/blob/ca82db0229de26dec2fc554353838ad8e6fc5401/src/sap.ui.core/src/sap/ui/base/ManagedObject.js#L1142-L1155
And since the key is undefined, the browser throws an uncaught TypeError.
Any other information? (attach screenshot if possible)
After reading https://github.com/SAP/openui5/issues/544, I thought objectBindings is supported at least in fragments but there it fails too.
Also the description of objectBindings in the API reference ...
objectBindings: object A map of binding paths keyed by the corresponding model name. Each entry with keykin this object has the same effect as a callthis.bindObject(objectBindings[k], k);.
... is a bit weird to me since bindObject awaits an object as the only argument.
But according to the description above, this.bindObject(path, modelName) will be called. In the real code, on the other hand, it's this.bindObject(bindingInfo) again.src
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.