Nandan Chaturvedi
Nandan Chaturvedi

Reputation: 1098

How to know all available models in an SAPUI5 application?

While trying to debug a big complex application, I came across that there are plenty of models created in it for different purposes.

Apart from the fact that this is a wrong approach of coding, I am trying to find how can I know the list of all models that are made available to the application.

Any useful methods?

Upvotes: 1

Views: 2061

Answers (3)

krisho
krisho

Reputation: 1044

Just use the UI5 chrome add-on https://chrome.google.com/webstore/detail/ui5-inspector/bebecogbafbighhaildooiibipcnbngo

By the way, it is not the wrong approach to have multiple models.

Upvotes: 1

memeladon
memeladon

Reputation: 58

To see all models available to the control, use the following:

Object.assign({}, control.oModels, control.oPropagatedProperties.oModels)

To log all models created during app lifetime, one can monkey-patch the sap.ui.model.Model constructor and add logging capabilities there.

Upvotes: 2

KristoffDT
KristoffDT

Reputation: 471

If you want to retrieve all models bound to your view, you could use this.getView().oModels to see all existing models for that view.

I don't know of a way to retrieve all models used in your application, but I assume that in order to debug your issue, you at least have access to the View on where your bug is located.

Upvotes: 2

Related Questions