UI5
For example, I draw a button on the UI5 interface and then pop up an alert dialog.
Only the name of the controller and the name of the event handler function are defined in the XML view. Then when the button is clicked, the controller's Onshowhello is triggered. But when was the instance of the controller created and associated with the XML view that declares it?
In Xmlview.js, after the source code of my defined XML view is loaded, Xmlview invokes Xmltemplateprocessor to parse the contents of the XML view, creating the corresponding UI5 control instance according to the control declaration inside. The variable _xcontent.innerhtml is the source code for the XML view.
After the instance of Xmlview is created through Factory mode, the controller name SAP.UI.DEMO.WALKTHROUGH.CONTROLLER.APP defined in the Xmlview source code is assigned to the field of the Oview instance. On the controllername.
The binding of view and controller is done by this method Createandconnectcontroller:
Connect controller to view after controller and control tree is fully initialized
Instances of the controller are also created through Factory mode:
Once the Connecttoview is executed,
The relationship between Oview and Ocontroller was set up.
CRM WebClient UI
Each UI component view has a built-in property controller that points to the controller instance of the view.
In the BSP programming environment, developers do not have to worry about the initialization of this controller instance directly.
So when did the controller instance of the view be initialized by the framework?
To figure this out yourself, you can find a BSP UI component to do an experiment. I'm looking for a prdhs. Set breakpoints in the constructor of its view controller Cl_prdhs_header_impl:
Open the view, and from the context of the call stack, know where the BSP framework initializes the controller instance. Note this instance at ABAP Runtime's address number 4633:
Similar to UI5 logic, within Cl_bsp_page_base~create_page, line 190th creates an instance of the controller and associates it with the view instance.
The last run-time view of the controller instance 4633 and before we in the Prdhs/header controller Cl_prdhs_header_impl's constructor of the Me pointer 46,331-like, proves that two variables point to the same instance.
To get more original Jerry's technical articles, please follow the public number "Wang Zixi" or scan the QR code below:
How the view and controller of the SAP UI5 and CRM WebUI are bound