OpenWGA 7.5 - OpenWGA Concepts and Features

Design and development » TMLScript

Base objects

The TMLContext object

The primary base object of TMLScript is the TMLContext. This object is the TMLScript representation of the WebTML document context like it s also used by WebTML tags to have access to a certain content document.

A TMLScript code has always a base context that is available to the script as Object "this". If the code is executed by a WebTML tag then this context equals the context of this tag. Other TMLScript functionalities have base contextes that are dependent on their respective purpose.

Tags and attributes that are used in WebTML to retrieve or test data from the context document often have their pendants in methods on the TMLScript object. For example:

The usage of  the qualifier"this" to reference the base context is implicit in TMLScript. It can be omitted when referencing methods and properties of it:

// Equal retrievals of item value "body"
this.item("body")
item("body")


Just like in WebTML a TMLContext supports context changes. It offers a method this.context() for that purpose that accepts the same context expressions as the context attribute on WebTML tags. The result of this method is again a TMLContext object that represents the addressed context.

So the following code can be used from any script to retrieve the item value of "body" from the document of name "home":

this.context("name:home").item("body")

// or

context("name:home").item("body")

The WGA object

The "WGA" object provides a wide range of functionality in TMLScript that is not directly dependent on the current WebTML context.

Common usages are:

The WGA object also allows access to some subobjects which provide functionality related to some common topic:

  • WGA.Auth provides authentication related functionality
  • WGA.Html offers tools to parse and load HTML code
  • WGA.Master allows running TMLScript code chunks in a "master session"
  • WGA.Utils is the WGAPI object offering generic purpose utility methods
  • WGA.Xml offers tools to parse and load XML code
  • WGA.design() allows to retrieve resources from a specifc OpenWGA design
  • WGA.lucene() offers methods to utilize all things related to the Lucene fulltext index of OpenWGA 
  • WGA.plugin() offers information about installed OpenWGA plugins

The "WGA" object was introduced with OpenWGA 5.3. Before that most of the functionality available on it was available as various methods on the TMLContext object or as "global functions". This functionality was reorganized with version 5.3 to prevent name collisions with the functionality offered by "this" when introducing new global TMLScript features  and also to group methods of common topic on subobjects to allow easier discovery.

The previous versions of the "WGA" functionality remain available in current OpenWGA versions for backward compatibility, but are no longer documented because their usage is discouraged.

Also at current state some functionalities that by definition would better fit into the "WGA" object for now remain on the "TMLContext " object. They may be introduced to the "WGA" object with later releases.