question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ManagedObject: "objectBindings" support in XML view / fragment definitions

See original GitHub issue

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 key k in this object has the same effect as a call this.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

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
flovogtcommented, Jul 17, 2020

Hello @boghyon ,

Thank you for sharing your enhancement proposal. I’ve created an internal incident 2080221780. The status of the issue will be updated here in GitHub.

Regards, Florian

1reaction
flovogtcommented, Jul 17, 2020

Hi @boghyon, we’ve discussed your enhancement proposal and agreed on implementing it. The BLI is CPOUI5FRAMEWORK-122. This issue will be updated when the BLI is implemented. Best Regards, Florian

Read more comments on GitHub >

github_iconTop Results From Across the Web

SAPUI5 Reusable Table Fragment Data Binding
As hopefully shown in this sample, I want to pass a specific model property to the fragment and its table to display a...
Read more >
Require Modules in XML View and Fragment - SAPUI5 SDK
Modules can be required in XML views and fragments and assigned to aliases which can be used as variables in properties, event handlers,...
Read more >
XML view, Formatter within XML Fragment not accessable ...
Dear UI5 experts, I'm struggling for a longer time with a problem using a formatter function with an XML fragment definition.
Read more >
View Binding - Android Developers
Use view binding in activities; Use view binding in fragments ... generates a binding class for each XML layout file present in that...
Read more >
Creating and Using Fragments | CodePath Android Cliffnotes
A Fragment is a combination of an XML layout file and a java class much like an Activity . Using the support library,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found