cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to override standard methods using Adaptation project in Business Application Studio

Rakesh_Kr
Participant

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

0 Kudos

Hi Expert,

I'm also facing the same issue. if anyone find the solution please update here.

HI Rakesh if you have found the solution please help me also.

harianantha
Participant
0 Kudos

Hi rakesh_personal amarjeet_atci

I'm also facing the same issue. I have tried many ways but no luck. Please help me if you find any solution.
Thank you!!

Rakesh_Kr
Participant
0 Kudos

Hi Together,

It seems sap only allows to overwrite basic lifecycle methods using BAS adaptation project and we can't overwrite all standard methods like we do in WEBIDE extension projects. SAP is suggesting using WEBIDE Personal edition or cloud version if available.

Also, it seems sap is working to provide extension project functionality for BAS as well, but not sure where it is on the roadmap.

Please add if you could find any alternative solution for this.

rakesh2901
Participant
0 Kudos

Hello All,

Any luck with this?? , I also need to extend a standard method.

Regards

Rakesh

friendlycoder
Participant
0 Kudos

Hello All,

Any luck with this?? , I also need to extend a standard method.

Regards

View Entire Topic
guilherme_maeda
Explorer

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 Metadata

By 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 the onInit, onExit, onAfterRendering and onBeforeRendering 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() {
                // ...
            }
        }
    });

});
MelaiSaldua
Explorer
0 Kudos
Hi guilherme_maeda, I tried your approach on how to overwrite private methods however I am unable to access the exact controller. The controller is inside the ext/controller. When I try to access this path in the console, I am unable to. Do you have a way on how to do this?