0
votes

Here is my actual situation:

I'm currently working on an application using UI5 and the MVC-principle. For functional reasons I have created a custom control. In this custom control there are a view functions (beside that I'm using a controller and a view).

Now, this is the actual question: How do I call a function from the custom control?

I have no problem with calling functions from my controller, but I am not able to call a function from my custom control.

Details: In my "App.view.xml" I have linked my controller and my custom control:

<mvc:View xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="..." xmlns:core="..." xmlns:l="..." xmlns:f="..." xmlns="..." xmlns:customControl="..." controllerName="..." displayBlock="true">

I tried to call a function from custom control as follows:

<Button xmlns="sap.m" xmlns:customControl="..." text="Description" press="functionfromcustomcontrol"/>

Can anyone tell what's wrong with this code or what should I do to solve this problem?.

I've research alot but didn't found what I'm looking for. Thanks in advance for your help.

1

1 Answers

0
votes

The XML

<Button xmlns="sap.m" xmlns:customControl="..." text="Description" press="functionfromcustomcontrol"/>

looks odd. I assume that you defined an own "Button" as CustomControl derived from the sap.m.Button. Then the XML should look like this:

<customControl:Button text="Description" press="functionfromcustomcontrol"/>

Just take a look at the openUI5 Walkthrough Step 34: Custom Controls to get an example