Reputation: 11
We are trying to extend a standard Fiori app via Adaptation project in WebIDE. We are trying to overwrite a function that is in ext/controller/SourceOfSupplyList.controller.js but is even unable to even access the controller (SourceOfSupplyList) in the controller extension file. Is there way to do this?
Below is our code. We could access the utils path and the files inside but we are even unable to access the ext/controller path.
sap.ui.define([
'sap/ui/core/mvc/ControllerExtension',
'sap/ui/core/mvc/OverrideExecution',
'ui/s2p/mm/sspreq/manages1/utils/formatter'
],
function (
ControllerExtension, OverrideExecution, formatter
) {
"use strict";
return ControllerExtension.extend("customer.zTest.SourceOfSupplyListExtension", {
metadata: {
// extension can declare the public methods
// in general methods that start with "_" are private
methods: {
publicMethod: {
public: true /*default*/ ,
final: false /*default*/ ,
overrideExecution: OverrideExecution.Instead /*default*/
},
}
},
override: {
onInit: function () {
alert("onInitOverride");
const originalPrototype = Object.assign({}, formatter);
formatter.supplierFieldControl = function (oEvent) {
// we could overwrite the function in the formatter just fine
console.log("supplierFieldControlExtension");
// you can still call the original method too
originalPrototype.supplierFieldControl.apply(this, arguments);
};
console.log(ui/s2p/mm/sspreq/manages1/ext/controller/SourceOfSupplyList); //unable to access ext/controller
debugger;
}
}
});
});
Below is our original apps folder structure in WebIDE
Upvotes: 0
Views: 703
Reputation: 18044
You should be able to access the methods of the base controller from this.base
within the extension code. This is documented in the topic "Controller":
Within the methods of a controller extension, the reserved
base
member allows access to the public functions of the extended controller. Functionality can be called by usingthis.base.basePublicMethod()
.
Upvotes: 0