Quantcast
Channel: SCN : Blog List - All Communities
Viewing all articles
Browse latest Browse all 2548

SAPUI5 Walkthrough, And Dive In - Step 2: Bootstrap

$
0
0

This is the first of my SAPUI5 Walkthrough, And Dive In blog series, where I’ll not only walkthrough the tutorial, but dive in, to explore the magic behind SAPUI5.


Buckle up and sit tight, it's gonna be a bumpy ride as I’m no expert in any way shape or form, just a humble learner who loves coding and likes to get to the bottom of things

 

Let’s kick off our journey with Step 2: Bootstrap https://sapui5.netweaver.ondemand.com/sdk/index.html#docs/guide/fe12df2e338e43598977d09f3d191b7b.html of the walkthrough tutorial.

 

01.png

This is pretty straight forward, but how exactly the function() { alert(“UI5 is ready") } got called by the SAPUI5 framework? 

 

Let’s first take a look at the implementation of the attachInit method.

 

It is defined in sap-ui-core.js which we included in our index.html page, when it's called, it pushes our function into the array this.aInitListeners.

02.png

And the this._executeInitListeners() method is where our function is actually being called, it loops through all the functions in the this.aInitListeners array, then have them to be called.

03.png

And how’s the this._executeInitListeners method called? Here’s my findings after debugging:

 

As you can see in the screenshot below, we create a new instance of the Core.

04.png

 

In the constructor method of the Core, these methods will be called:

that.handleLoad() // called upon document ready

     |

this.init()

     |

this._executeInitListeners()

 

And how’s new Core().getInterface() called? That’s where things get really interesting, to answer this question, we’ll be able to take a peek at how SAPUI5 define it’s module, journey continues...

 

During the sap-ui-core.js loading process, let’s focus on two method calls, sap.ui.predefine('sap/ui/core/Core', aDependencies, vFactory, bExport) and jQuery.sap.require('sap.ui.core.Core’).

 

sap.ui.predefine('sap/ui/core/Core', aDependencies, vFactory, bExport) // registers core module to the global mModules, module.state = PRELOADED

05.png

                    |

jQuery.sap.require('sap.ui.core.Core') // ensures that the given module is loaded and executed before execution of the current script continues

06.png

                    |

ui5ToRJS('sap.ui.core.Core') + '.js' // converts 'sap.ui.core.Core ' to requireJS module name syntax 'sap/ui/core/Core.js'

                    |

requireModule('sap/ui/core/Core.js') // sets module.state = LOADED

                    |
execModule('sap/ui/core/Core.js') // sets module.state = EXECUTING

                    |

sap.ui.define.apply(sap.ui, module.data) // calls sap.ui.define with module.data as argument 

07.png

                    |

sap.ui.define('sap/ui/core/Core’, aDependencies, vFactory, bExport) // defines a Javascript module with its name, its dependencies and a module value or factory.

08.png

                    |

requireAll('sap/ui/core/', aDependencies, callback) // resolves dependencies

09.png

10.png

                    |

// we got finally took back to the factory function with all the dependencies in place, and by the end of it, the call instance will be created, and with its interfaces returned as the Core module content, the end

11.png

04.png


Viewing all articles
Browse latest Browse all 2548

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>