Skip to Content
0
Jan 16, 2021 at 06:22 PM

resourceBundle Error - SAP UI5

287 Views

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();
} }); });;