cancel
Showing results for 
Search instead for 
Did you mean: 

How to access named Models defined in manifest.json ?

Former Member
0 Kudos
7,030

Hi Experts,

I have created a custom UI5 application using HCP WebIDE. I create models in manifest.json. Models are getting executed and I am able to see the data in controls.

My question is how can I access named models in my controller ? For example : In below screen shot I have defined a model called "countrySet". I want to access this named model in controller of my view.

Do I need to set Model/SRV in component.js  ? If yes, how to do it ?  

Thanks and Regards

Abhijeet

View Entire Topic
D_Chia
Active Participant

if you are not at controller of your 'rootView' of the UIComponent,

this.getOwnerComponent().getModel("countrySet")          // 'this' being the controller of the view

else

this.getView().getModel("countrySet") would suffice         

// eg. view=>App.view.xml and App is the 'rootview' specified in manifest.json

Former Member
0 Kudos

Hi D.Chia,

Thanks for you quick reply.

this.getOwnerComponent().getModel("countrySet")  // Working fine I am able to retrieve data.

this.getView().getModel("countrySet")  // Undefined .. I think I need to execute this in APP view controller or Component.js.

I have one more question related to it. How do you access default model / Service defined in manifest.json.

Thanks and regards,

Abhijeet

D_Chia
Active Participant

the default model is also known as the "unnamed" model.

thus you just need to call the getModel method without passing any parameter/name


this.getOwnerComponent().getModel()