How the view and controller of the SAP UI5 and CRM WebUI are bound

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.