cancel
Showing results for 
Search instead for 
Did you mean: 

resourceBundle Error - SAP UI5

praveen_kumar194
Active Contributor
0 Kudos

Dear Team,

I am following tutorial using business application studio and facing this below error. i tried to search the forum. got few threads however did not help me to resolve the issue.

no matter which method i tried, i keep getting syntax error saying 'getResourceBundle' is not part of model. I am sending "sap/ui/model/resource/ResourceModel" module. then i am setting the resourcemodel like below.

var rmodel = new ResourceModel( {
bundleName : "My.Learning.webmodule.i18n.i18n" } );

this.getView().setModel(rmodel,"i18n");

after that i am trying to read the resource bundle with below syntax.

var oBundle = this.getView().getModel("i18n").getResourceBundle();

after getModel("i18n"), after pressing dot, even context help is not showing the getResourceBundle method. Below is the full source code.

am I missing something ? Please help.

sap.ui.define([ "sap/ui/core/mvc/Controller", "sap/ui/model/resource/ResourceModel" ], /** * @param{typeof sap.ui.core.mvc.Controller}Controller */ function (Controller,ResourceModel) { "use strict";
return Controller.extend("My.Learning.webmodule.controller.View", { onInit: function () {
var rmodel = new ResourceModel( {
bundleName : "My.Learning.webmodule.i18n.i18n" } );
this.getView().setModel(rmodel,"i18n");
}, onClick : function() { var oBundle = this.getView().getModel("i18n").getResourceBundle();
} }); });;
View Entire Topic
prashil
Advisor
Advisor

Hi Praveen,

The best pratice of creating resourceModel is in manifest.json under sap.ui5 -> models.

There is nothing wrong with the way you create resourceModel it's just that it is applicable only to the view.

Coming to your question, I tried the same at my end and everything works seamlees, there is nothing wrong. Are there any console errors?

Thanks

Prashil

praveen_kumar194
Active Contributor
0 Kudos

Thanks prashil. The error I am getting is get resource bundle method is not part of the model. Studio would highlight this method with simple red underline as syntax error and code would not compile. Not sure what is the error here. I am doing this in business application studio. Pls help