A lookup table 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, i.e. "looked up".
A pair of key and value (the object to store) in a lookup table is named "element". A key can only be used by one element in a lookup table. A special value in contrary can be contained in many elements if it is stored under differing keys.
To read the value of an element from the table use table.get with the key of the element. To create or update an element with a new value use table.put with key and value as parameters.
Keys and values of a lookup table may technically be any type of object, but mostly trivial objects like strings or numbers are used as they can be easily compared and reproduced. String keys are case sensitive. You can store different elements under keys "Key", "key" and "KEY".
From a Java perspective lookup tables are just the TMLScript view of Java interface java.util.Map
Via many methods, but mainly by:
|Allowed in script types||
|Properties and methods||
This example creates a table and fills it with month numbers as keys, storing the corresponding month name as values:
months = WGA.createLookupTable();
Such a table could be used in WebTML code to lookup month names by their numbers: using the get() method:
The month is <tml:script expression="months.get(monthnr)"/>
(Note that this is not really a recommendation for storing month names but only a demonstration of map usage. Month names can and should be generated just by formatting dates with approprate formatting rules)