cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Handler for Button not called in adaptation

Boguslaw
Explorer
0 Likes
1,404

Hello everybody,

I try to extend a standard App "Create maintenance request" (F1511A). I have added a Fragment with button and the button is available:

Boguslaw_0-1751964920561.png

My Fragment look like this:

<core:FragmentDefinition xmlns:core='sap.ui.core' xmlns='sap.m'>
    <Button id='LorCapBtn' text="LorCap" press='extension.customer.create.notif.variant.onLorCapPress'/> 
</core:FragmentDefinition>

The controller:

sap.ui.define(
    [
        'sap/ui/core/mvc/ControllerExtension'
        ,'sap/m/MessageBox'
        // ,'sap/ui/core/mvc/OverrideExecution'
    ],
    function (
        ControllerExtension
        ,MessageBox
        // ,OverrideExecution
    ) {
        'use strict';
        return ControllerExtension.extend("customer.create.notif.variant.MainCntrlExt", {
            onLorCapPress : function(oEvent){
                console.log("onLorCapPress called");
                MessageBox.success("Hello");
            },
});
    }
);

When I press the button nothing happened (no massege box, no message in console).

Do you know what is the problem? What have to be done to run my code?

Regards,

Boguslaw

 

 

 

 

Accepted Solutions (1)

Accepted Solutions (1)

junwu
SAP Champion
SAP Champion
0 Likes

Probably you are missing the . before the extension,  MainCntrlExt is also missed

 

<core:FragmentDefinition xmlns:core='sap.ui.core' xmlns='sap.m'>
    <Button id='LorCapBtn' text="LorCap" press='.extension.customer.create.notif.variant.MainCntrlExt.onLorCapPress'/> 
</core:FragmentDefinition>

 

Boguslaw
Explorer
0 Likes

Hi Junwu, thx for your hint - the dot was missing, the second part the was missing as well, was the cntroller name. The correct path to my handler is: 

<core:FragmentDefinition xmlns:core='sap.ui.core' xmlns='sap.m'>
    <Button id='LorCapBtn' text="LorCap" press='.extension.customer.create.notif.variant.MainCntrlExt.onLorCapPress'/> 
</core:FragmentDefinition>

Answers (2)

Answers (2)

Marian_Zeis
Active Contributor
0 Likes

I think your namespace in the button is wrong, you're missing MainCntrlExt

Try:

.extension.customer.create.notif.variant.MainCntrlExt.onLorCapPress

Marian_Zeis
Active Contributor
0 Likes
Oh, I'm on mobile and did not see the answer, good to know I got the right answer 😄
Boguslaw
Explorer
Thank you anyway 🙂
FabioPagoti
Active Contributor
0 Likes
<core:FragmentDefinition xmlns:core='sap.ui.core' xmlns='sap.m'>
    <Button id='LorCapBtn' text="LorCap" press='.onLorCapPress'/> 
</core:FragmentDefinition>

have you tried this?

Boguslaw
Explorer
0 Likes

Hi Fabio, thx for your answer. I have just tried your proposal - it does'n work. In SAP Fioti Toll user guide is decribed that the function name for press event should have a prefix ".extension.<controller extension namespace>."

FabioPagoti
Active Contributor
0 Likes
Please share the manifest where extensions are declared as well