on ‎2022 Aug 31 8:56 PM
Hi Guys,
I am trying to understand & learn some concepts of UI5 and I was going through some tutorials but rather than copying thoughlessly code from tutorials I prefer understanding what is happening below the surface.
One of the examples I encountered was handling the class sap.m.image event press. According to the API reference event is fired, which I handled in a View Controller in a line:
onImagePress: function(oEvent){
var oSOurce = oEvent.getSource();
var ID = oSOurce.getId();
}
I wanted to get the Source and finally get the ID of the image.
Here unfortunatelly comes my question. According to API reference, getSource of oEvent returns object of class EventProvider:


Although the class is marked in API to be abstract it can be instantiated (according to API ref., which is in contradiction to my understanding of abstract classes).
I was trying to understand where does the availability of method getId come from and tried to debug the Event.js but without any spectacular results. I was hoping that maybe methods like oSOurce.constructor.name could help but not really.
Event.prototype.getSource = function() {
return this.oSource;
};
Request clarification before answering.
Try to use TypeScript for your ui5 app. This has the concept of real classes including abstract classes. Here you have the getting started
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.