view controller lifecycle discussion - onInit

Created by Jerry Wang, last modified on Aug 08, 2014

新建一个view instance:


view controller lifecycle discussion - onInit


Callstack2: 这个view的实例化会调用下图所示的另一个function ( r["view"] ). 传入function的参数就是上图中的对象字面量,也就是指定的view detail。


view controller lifecycle discussion - onInit


Callstack3: 进到callstack2 所示的function中去,因为待构造的view类型是JS view,因此进入相应分支:


view controller lifecycle discussion - onInit


Callstack4: 可以发现JSView constructor是采取lazy load的方式进行加载的:




view controller lifecycle discussion - onInit

line 9292行会把执行delegate给下一个function r.



Callstack5: this 指向正在初始化的view instance.




view controller lifecycle discussion - onInit

可以发现这个_initCompositeSupport function 函数体内会抛一个AfterInit的event。

view controller lifecycle discussion - onInit


Callstack6: 这里的this就是view instance,this.oController就是view controller instance。


view controller lifecycle discussion - onInit

把鼠标放在onInit上能观察到我们在Eclipse里写的code。

view controller lifecycle discussion - onInit


Callstack7: 重用EventProvider的fireEvent方法来raise event:


view controller lifecycle discussion - onInit

Callstack8: I.fFunction就是controller里实现的onInit方法,oListener就是controller,oListener.oView就是view本身。


view controller lifecycle discussion - onInit

于是最终call到controller的onInit方法:

view controller lifecycle discussion - onInit

上一篇:SAP CRM Fiori Opportunity应用功能一览


下一篇:SAP Fiori架构一览