Systems

JavaScript in InsuranceSuite is organized into many systems. A system is a singleton object that is registered in a global table and is optionally notified after every server request. You can add your own systems using the gw.api.registerGlobalSystem API, which takes a system object as its argument.

A system must have a getSystemName function, which returns a unique name for the system.

A system can also have an init function, which is called after each server request. The init function has the Boolean argument isFullPageReload. which indicates the following:
  • If true, the server request was a full page reload (for example, a GET, which usually happens only when logging in or out).
  • If false, the server request was a normal AJAX request.
Once the system is registered, it is available as gw.globals.xxx, where xxx is the name returned by getSystemName. For example:
(function () {
  if (gw.globals.mySpecialSystem) {
    // System already defined
    return;
  }
  gw.api.registerGlobalSystem({
    getSystemName: function () { return "mySpecialSystem"; },
    init: function (isFullPageReload) {
      // Called whenever there is a server request
    }
  });
})();