OpenWGA 7.11 - TMLScript reference

Method :

label([[container,] file,] key [, params])
label(key, map)

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.


Variant 1:

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.

Variant 2:

key (String):
The key of the label

map (Map)

config map with keys (all optional)

  • container
  • file
  • params
  • placeholder
  • language

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");