OpenWGA 5.4 - TMLScript reference



Description This object represents the configuration of a specific WebTML portlet for the current browser user. It mainly consists of a number of items that may influence behavior and appearance of the portlet. Those items can be set via portlet.setitem() and read via portlet.item() or in WebTML via <tml:item type="portlet"/>. Like on content and profile documents modified items must be saved via so they get stored.

There is a shortcut syntax for reading items by just specifying their name as properties (in lower case) on the TMLPortlet object.

Additionally a portlet may hold "portlet variables" which are special versions of WebTML variables that are only visible in the scope of the portlet they were defined for. Set them via setvar() or portlet.setSessionVar(). Read them - as all WebTML variables - via the this.item method of the TMLContext.

The TMLPortlet object additionally grants control about some status settings of the portlet, like its mode, its position in the portlet hierarchy and the WebTML module that forms its layout. Additionally it can be used to modify the portlet registration, like to register or unregister portlets.

Portlet configurations are stored on the users personalisation profile. Therefor there is neither portlet registration nor portlet configuration available when the user has no profile.

The portlet object that is accessed in TMLScript is normally the object that represents the "current" WebTML portlet available as this.portlet. The current portlet is the portlet whose WebTML code is currently rendered. A portlet is rendered by specifying a <tml:portlet> tag on a WebTML page. If the current TMLScript code is not contained in any <tml:portlet> tag then this.portlet represents the implicit "root portlet" which is available without registration and serves as parent portlet for all manually registered first-level portlets.

All methods and properties of this objects are case insensitive and may be used in arbitrary cases though we recommend using the cases that are used in this documentation.

Retrieval this.portlet for the "current" WebTML portlet
portlet.getPortletForName() to retrieve a portlet for a specific name
portlet.parentPortlet to retrieve the parent portlet of the "current" portlet
portlet.registerPortletForName() to register a new portlet under a given name
Allowed in script types
  • WebTML pages and normal WebTML actions
Properties and methods
Name Purpose
portlet.childrenNames Returns the names of the child portlets
portlet.cleanup() Clears the portlet configuration
portlet.context Gets/sets the portlet context
Throws a portlet event
portlet.getPortletForName(name) Returns the TMLPortlet object for the child portlet of the given name
portlet.getSessionVar(varname) Retrieves a WebTML portlet session variable
portlet.getVar(varname) Retrieves a normal WebTML portlet variable
portlet.hasItem(itemname) Tests if an item exists on the portlet configuration
portlet.item(name) Returns the value of an item from portlet configuration
portlet.itemList(name) Returns values of portlet items as list
portlet.mode Returns the current portlet mode Returns the name of the portlet
portlet.getSourcePortlet(portletEvent) Returns the portlet that threw a portlet event
portlet.root Retrieves the root portlet
portlet.parentPortlet Returns the parent portlet of the current portlet
portlet.registerPortletForName(name [, moduledb] , module [, overwrite]) Registers a new portlet or changes the registry of an existing portlet
portlet.removeItem(name) Removes an item from portlet configuration
portlet.removeSessionVar(name) Removes a WebTML portlet session variable
portlet.removeVar(name) Removes a WebTML portlet variable Stores changes to the portlet configuration
portlet.setItem(name, value) Sets an item in portlet configuration
portlet.setMode(mode) Sets the portlet mode of the current portlet
portlet.setSessionVar(name, value [, allowSerialisation]) Sets a WebTML portlet session variable
portlet.setVar(name, value) Sets a WebTML portlet variable
portlet.tml Returns the name of the layout WebTML module for this portlet
portlet.tmlDb Returns the key of the application containing the layout module
portlet.unregister() Removes the current portlet from portlet registry.
portlet.unregisterChildPortlets() Removes all child portlets
portlet.unregisterPortletForName(name) Removes a child portlet from registration
Examples Reading a portlet item, once in full once in shortform syntax:

Registering a portlet from TMLScript:
var newPortlet = portlet.registerPortletForName("childPortlet", "myportletmodule");
newPortlet.setItem("key", KEY);;