OpenWGA 7.11 - TMLScript reference

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:"WGUtils", "de.innovationgate.utils.WGUtils"); // Registers a Java class as TMLScript-Global"WGAPI", "de.innovationgate.webgate.api"); // Registers a Java Package..."TheDB", db("mydb"); // Registers a java object"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;