OpenWGA 7.0 - TMLScript reference

Design
Method :

registerGlobal(name, ref)

On object Design
Usage Defines a "TMLScript global" variable
Description A "TMLScript global" is an object which is available to all TMLScript code that runs on the OpenWGA server. It is stored under a specified name which can be used as reference in all those TMLScript codes.

Normal TMLScript globals are available to all TMLScript code of the server. This is suitable if it represents a general tool that wants to extend the language capabilities of TMLScript itself and therefor should be widely available without limits. So unlike other functions of the design context this method does not really take the current design into account but registers the global object for the whole TMLScript runtime.

If the object however should only be used in the current design you should consider using Design.registerDbGlobal() which will reduce its scope to the current design.

Find out more on TMLScript globals in Concepts and features.

For backward compatibility there still is a global function "registerGlobal()" available on TMLContext whose use is discouraged since OpenWGA 5.3.
Parameters name (String):
Name by which the variable will be known. Global names must start with an uppercase letter.

ref (String | Java-Objekt | TMLScript-Objekt):
The object to store inside the variable
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
Examples Some examples using different types of objects as TMLScript globals:

WGA.design().registerGlobal("WGUtils", "de.innovationgate.utils.WGUtils"); // Registers a Java class as TMLScript-Global
WGA.design().registerGlobal("WGAPI", "de.innovationgate.webgate.api"); // Registers a Java Package...
WGA.design().registerGlobal("TheDB", db("mydb"); // Registers a java object
WGA.design().registerGlobal("ScriptObject", { myVal: "Test" }); // Registers a TMLScript object


Example usages of these globals:

var str2 = WGUtils.strReplace(str1, "x", "y", true);
int doctypeContent = WGAPI.WGContent.TYPE_CONTENT;
var dbTitle = TheDB.getTitle();
var theVal = ScriptObject.myVal;