I am trying to create an adaptation project based on the SAP UI standard application ‘Monitoring of purchase requisition items’.
I want to hook a data receive event when the Go button on the screen is pressed.
I could hook an event when the Go button is pressed.
However, I could not hook the data receive event on the screen after the Go button is pressed.
I have created following extension controller.
However, “onDataReceived” does not work.
How can I hook data receive events?
/***
@controller Name:sap.suite.ui.generic.template.AnalyticalListPage.view.AnalyticalListPage,
*@viewId:ui.s2p.mm.pritem.monitors1::sap.suite.ui.generic.template.AnalyticalListPage.view.AnalyticalListPage::C_PurReqnItemMntrResults
*/
sap.ui.define([
"sap/ui/core/mvc/ControllerExtension"
, "sap/ui/core/mvc/OverrideExecution"
, "sap/ui/model/odata/v2/ODataModel"
, "sap/ui/model/json/JSONModel" ],
function (ControllerExtension, OverrideExecution, ODataModel, JSONModel) {
"use strict";
return ControllerExtension.extend("customer.monit01.testItem", {
metadata: {
// extension can declare the public methods
// in general methods that starts with "_" are private
methods: {
publicMethod: {
public: true /*default*/ ,
final: false /*default*/ ,
overrideExecution: OverrideExecution.Instead /*default*/
},
finalPublicMethod: {
final: true
},
onMyHook: {
public: true /*default*/ ,
final: false /*default*/ ,
overrideExecution: OverrideExecution.After
},
couldBePrivate: {
public: false
}
}
},
// adding a private method, only accessible from this controller extension
_privateMethod: function() {},
// adding a public method, might be called or overridden from other controller extensions as well
publicMethod: function() {},
// adding final public method, might be called but not overridden from other controller extensions as well
finalPublicMethod: function() {},
// adding a hook method, might be called or overridden from other controller extensions.
// override these method does not replace the implementation, but executes after the original method.
onMyHook: function() {},
// method per default public, but made private per metadata
couldBePrivate: function() {},
// this section allows to extend lifecycle hooks or override public methods of the base controller
override: {
/**
* Called when a controller is instantiated and its View controls (if available) are already created.
* Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.
* @memberOf customer.monit01.testItem
*/
onInit: function() {
// this._loadAdditionalData();
// call original onInit
//ControllerExtension.prototype.onInit.apply(this, arguments);
// add event handler
var oView = this.getView();
var oGoButton = oView.byId("ui.s2p.mm.pritem.monitors1::sap.suite.ui.generic.template.AnalyticalListPage.view.AnalyticalListPage::C_PurReqnItemMntrResults--template::SmartFilterBar-btnGo");
if (oGoButton) {
oGoButton.attachPress(this.onGoButtonPress, this);
}
},
/**
* Hook data receive event.
* This doesn't work.
* /
onDataReceived: function(oData){ // oSomeData will be passed in
if (oData && oData.status === "important") {
oData.message = oData.message + "!!!";
}
}
},
onGoButtonPress: function (oEvent) {
console.log("GO button pressed");
},
});
});
Thank you very much in advance.
Ryo
Ryo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.