Code locality basics

The CXP:Infrastructure allows you to define the code locality. Code locality is a feature for controlling the position where your Xbase++ code is injected into the page class. By default, all Xbase++ code is injected into the ::Render() method of your page class, in the order the code appears in your CXP file. However, sometimes it is required to create classes or helper functions to better structure the code, or to make certain code sequences reusable. For this the CXC Builder knows a couple of meta tags for controlling code locality. The basic usage is shown in this example. Code locality is a great feature to avoid so-called code soup which is a common problem in PHP and other comparable technologies. Other locality identifiers are page-load and page-unload for code to be executed when your binary (your page dll) gets loaded into or unloaded from memory. The page-init locality allows the injection of code at the end of the page object's :Init() method, which means the code will be executed prior to any render method. Page-global code, on the other hand, never gets executed automatically by the framework. Instead, the page-glocal locality is used for things which are used by the page code itself.

Related articles:
Run in new tab
Live editor
Result built with V2 2156
I'm a warning toast!
I'm a success toast!