on 08-05-2022 2:06 PM
Hello Experts,
I am trying to extended standard fiori app F1706 add a feature to a standard application using Business Application Studio. As we have now only option of Adaptation Project, I created an Adaptation Project and extending controller, but it seems the override functionality is not behaving as expected.
I am unable to override the standard method inside my extended controller. It's not triggering it when i place it in override section of extended controller. Please find attached screen for reference.
Please note that onInit() method inside override section is triggering, but other standard method of the standard fiori app which i am using e.g. onDeliveryHeaderSelected is not getting triggered. Until this is triggered i can't place the custom logic on this event/method.
We don't want to use WEBIDE as it's BAS is something which is future and WEBIDE license will be expiring soon.
Basically we want to trigger an pop up message with few information based on item selected, but the event seems not working inside extended controller. Anyone with similar experience or solution, would be very useful.
below is the screen from standard app, and on select of any line item, onDeliveryHeaderSelected gets triggered, which I am trying to override.
Best Regards,
Rakesh
You cannot override the onDeliveryHeaderSelected method because methods that start with "on" are private by default unless the standard application controller declares it as public in its "methods" section, as explained in the Controller section of the UI5 documentation:
Methods
Section in the Controller MetadataBy default, all methods that do not start with an underscore or with prefix "on", "init" or "exit" are public. You can get all public methods of a controller by using the
oController.getMetadata().getPublicMethods()
API.
Only public methods and methods that are not flagged as final could be overridden by a controller extension.
Note: If you don't use the new
methods
definition for controllers, you could override theonInit
,onExit
,onAfterRendering
andonBeforeRendering
methods of the controller even if they are private by default.
You can override the private methods by modifying the original controller's prototype, as in the example below:
sap.ui.define([
"sap/ui/core/mvc/ControllerExtension",
"example/application/controller/Delivery.controller", // <-- standard controller
],
function (ControllerExtension, DeliveryController) {
const originalPrototype = Object.assign({}, DeliveryController.prototype);
DeliveryController.prototype.onDeliveryHeaderSelected = function(oEvent) {
// do whatever custom stuff you need
// you can still call the original method too
originalPrototype.onDeliveryHeaderSelected.apply(this, arguments);
};
return ControllerExtension.extend("customer.adapt.example.application.DeliveryExtension", {
override: {
// you can keep using the Adaptation API for the public methods
onInit: function() {
// ...
}
}
});
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.