OpenWGA 7.11 - TMLScript reference

WGA
Object:

WGA.Map([otherMap])

Description

Creates a WGAMap Object.

Available since version 7.11.12

A WGAMap is a collection of objects which are stored under individual keys. The keys then can be used to retrieve the object that was stored under that key,

Maps have a dynamic size. Elements can be added, inserted and deleted from the map. Their functionality is mostly equal to JavaScript object-s. They are effectively the TMLScript representation of the Java interface java.util.Map.

Retrieval WGA.Map()

The map object can optionally be initialised with another WGAMap object or a JavaScript object:

WGA.Map(otherMapObjectOrJSObject)

Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
Inherits from object Lookup table
Properties and methods
Name Purpose
clear() inherited Removes all elements from the table
containsKey(key) inherited Tests if the table contains an element with the given key
containsValue(value) inherited Tests if an element with the given value exists
filter(function)

Calls the function with each map element and returns the filtered map as WGAMap object for further method chaining.

get(key) inherited Reads the value of the element with the given key
isEmpty() inherited Tests if the table is empty
map(function)

Calles the callback funktion for each entrie in the map with key and value als parameter. The function should return any object. The result of this method ist a WGAList object containing the returned values.

put(key, value) inherited Creates or updates an element of the given key with a new value
putAll(table) inherited Adds all elements of the parameter table to this table
remove(key) inherited Removes the element of the given key from the table
size() inherited Returns the number of elements on the table
Examples
let map = WGA.Map();
map.put("firstname", "Otto");

// or initialize the WGAMap with a JS-Object:
WGA.Map({firstname: "Walter", lastname: "Wichtig"});