Why does onBeforeFirstShow work?

2020-04-12 09:16发布

I have been learning the master-detail demo, below is a snippet in Master.controller.js

onInit : function() {
    this.getView().addEventDelegate({
        onBeforeFirstShow: function () {
            this.getOwnerComponent().oListSelector.setBoundMasterList(oList);
        }.bind(this)
    });
}

I can not understand that event delegate because I haven't seen onBeforeFirstShow event is in any control/view API doc.

Is this is a just user-defined event or a pre-defined event?


I have tried

this.getView().addEventDelegate({
    onBeforeFirstShow: function () {
        console.log("onBeforeFirstShow");
    }.bind(this),
    onAfterRendering: function () {
        console.log("onAfterRendering");
    }.bind(this)
});

It seems that it happens before onAfterRendering. Besides:

  • this.getView().onAfterRendering returned function
  • this.getView().onBeforeFirstShow returned undefined.

I have searched in doc of Controller and View, and source code of sap.ui.core.mvc.Controller and sap.ui.core.mvc.View. There are only four lifecycle methods.

1条回答
啃猪蹄的小仙女
2楼-- · 2020-04-12 09:56

The event beforeFirstShow is available for the view because the view is a direct aggregation child of NavContainer. Other than that, there are currently also

  • afterHide
  • afterShow
  • beforeHide
  • beforeShow

Those events are triggered by sap.m.NavContainer on its child controls (in our case, the view) when navigation occurs and child controls are displayed/hidden.

查看更多
登录 后发表回答