when and where is getControllerName called

Created by Jerry Wang on Aug 07, 2014

localResources

registerModulePath

在开发js view时,需要实现一个方法getControllerName,并且正确返回该js view对应的controller name.

when and where is getControllerName called


Callstack1: 这个方法从根源上说是在实例化JS view时被触发:

when and where is getControllerName called


Callstack2: 以实例化时传入的参数来调用view方法:

when and where is getControllerName called


Callstack3: 在view方法内,调用constructor sap.ui.core.mvc.JSView创建一个新的JS view实例:

when and where is getControllerName called


Callstack4: 在_initCompositeSupport内部,调用function c. this指向正在初始化的Js view实例,s是传入的对象字面量。

when and where is getControllerName called


Callstack5: 在function c的实现内,JS view实例是实参,传入形参t, line 41call 形参的getControllerName方法,因而会call 到application view里实现的getController方法

when and where is getControllerName called

待application 返回controller name存入到变量d之后,UI framework将会以该名称创建一个controller instance:

when and where is getControllerName called


Lazy load:


when and where is getControllerName called

mymap.map传入方法q.sap.require:

when and where is getControllerName called


准备加载文件mymap/map.controller.js. 注意系统是怎样将mymap.map 转化成mymap/map.controller.js的:

when and where is getControllerName called


这里会去取对应的controller js文件。可见如果getControllerName 返回的controller内容不正确,这里将会load不了正确的controller文件。


when and where is getControllerName called

可以做个试验:故意返回一个错误的controller name:

when and where is getControllerName called

console里报错说找不到对应的controller文件:

when and where is getControllerName called


上一篇:Flink on Zeppelin 系列之:Yarn Application 模式支持


下一篇:repeated call of attachBrowserEvent