This framework has 3 major components: host environment, constructors, and the application.
The host environment is defined in the hostEnv.js file. It provides the following services to the application and constructors:
The host environment also provides a diverse collection of small utilities. Check the Natural Docs documentation for more detail.
Constructors are used to create complex GUI elements and useful JS libraries. They are loaded, dynamically and automatically, from the server as they are needed. They only need to be loaded once per session, as they are stored in memory in host.constructors. Here is a list of current constructors:
While the host environment and the constructors are generic, re-usable libraries, each application is highly specific and unique. But there are some common elements we can expect. For this example, I'll assume we're placing our application code in a JS namespace called app.*.
One could say that there are 4 layers: data, display, data logic, and display logic. But those last 2 tend to get mashed together in practice, so we can just call them logic.
The data you see in the display layer is an echo of the data in the data layer. Any changes to the data are first applied to the data layer, then the display is updated. In this way, data never needs to be parsed. And you can do anything you want to the display layer without losing anything important.
All of this data is stored in app.data. But this data may be in several formats - which brings us to the Data Cascade. Data from the server and various other sources might not arrive in an optimal, integrated format. So it will have to be converted into a Master Data Format used by this application. But some of the constructors might require a format (or data set) different from the Master Data Format. So the data is transformed once again to populate these gui elements. And this is the cascade: server data formats --> Master Data Format --> constructor-specific data. Changes to downstream data should be applied to the Master Data Format and cascaded downstream, or even written back to the server, re-loaded, and cascaded from there. When dealing with a lot of data, it's best to formalize this cascade early. It can get hairy otherwise.
The gui is laid out using the concept of 'panels'. Panels are divs with extra properties and behaviors that connect them with the services host environment. These are a empty rectangular containers used for layout and to track context. They may have their own keystroke behaviors and context menus. GUI elements are placed within the panels and inherit their context (need to add detail later). Each gui has a global resize function that lays out the gui based on the browser window size, gui state information, and other factors. It may also call the resize functions of gui elements embedded with the panels. In future development, the skin system could contain different resize functions for each skin, allowing completely different layouts for each skin.
Each gui has a global closer function. This function closes menus, floaters, and other momentary gui elements in response to a mouse click anywhere in the gui. This is included to duplicate the expected behavior of desktop guis.
This framework - and the rich client applications built with it - follow a set of general principles: