OpenWGA 7.6 - TMLScript reference

Method :

label([[String container,] String file,] String key [, List params])

On object Design
Usage Returns a WebTML label from the current design
Description This function is mostly identical to this.label(). It is designed to be used in WebTML actions and custom TMLScript objects to safely return labels from the same application that contains their TMLScript code.

When TMLScript code in actions or objects gets used "externally", i.E. it is called by other applications than those definining them, then the label() function on TMLContext might not use the right database to look for labels. It might use the calling application. So a designer should use this function instead to retrieve labels on all places that might be used that way.

For backward compatibility there still is an equally working global function "localLabel()" available whose use is discouraged since OpenWGA 5.3.

Parameters container (String, optional):
File container basename (without language suffix) holding label files. When omitted uses the currently active default container basename, "labels" if not determined.

file (String, optional):
Label file holding label definitions. When omitted uses the current active default filename, "general" if not determined.

key (String):
The key of the label

params (List of strings, optional):
Values that should be used as label parameters. The string at list position 0 is used as parameter 1, position 1 as parameter 2 and so on. Specify null as list element for parameters that should be cleared.
Return value A text label (String)
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
Examples When a custom TMLScript object is to use WebTML labels it wil deposit those label definitions inside the same design that also defines the object. To safely retrieve these labels the object code should use localLabel().

The following example defines a method "getContent()" inside a custom TMLScript object that should retrieve an error message via label. Note that the design context used is constructed with the current TMLScript object as reference parameter:

this.getContent() = function(name) {
    if (table.containsKey(name)) {
        return table.get(name);
    else {"myobject", "name.notfound");