OpenWGA 7.2 - TMLScript reference


Object:

portlet

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"/>.

Changed portlet registration and configuration data is stored automatically at the end of each request. The method save(), which was needed to store profile/portlet data in OpenWGA versions prior to 6, is still available for backward compatibility but does nothing now.

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
    portletevent
Properties and methods
Name Purpose
childrenNames Returns the names of the child portlets
cleanup() Clears the portlet configuration and state
clearChildState(name) Clears the state of a child portlet
clearState() Clears the portlet state
context Gets/sets the portlet context
fireEvent(event)
fireEvent(eventName)
Throws a portlet event
forceState() Forces a state on a portlet
child(name) Returns the TMLPortlet object for the child portlet of the given name
getSessionVar(varname) Retrieves a WebTML portlet session variable
getVar(varname) Retrieves a normal WebTML portlet variable
hasItem(itemname) Tests if an item exists on the portlet configuration
item(name) Returns the value of an item from portlet configuration
itemList(name) Returns values of portlet items as list
itemNames Returns the names of all items that are stored on this portlet configuration
mode Returns the current portlet mode
name Returns the name of the portlet
getSourcePortlet(portletEvent) Returns the portlet that threw a portlet event
root Retrieves the root portlet
parent() Returns the parent portlet of the current portlet
portletkey Returns the key of the portlet
portletPath Returns the absolute name path of this portlet
registerPortletForName(name [, moduledb] , module [, overwrite]) Registers a new portlet or changes the registry of an existing portlet
removeItem(name) Removes an item from portlet configuration
removeSessionVar(name) Removes a WebTML portlet session variable
removeVar(name) Removes a WebTML portlet variable
setItem(name, value) Sets an item in portlet configuration
setSessionVar(name, value [, allowSerialisation]) Sets a WebTML portlet session variable
setVar(name, value) Sets a WebTML portlet variable
tml Returns the name of the layout WebTML module for this portlet
tmlDb Returns the key of the application containing the layout module
unregister() Removes the current portlet from portlet registry.
unregisterChildPortlets() Removes all child portlets
unregisterPortletForName(name) Removes a child portlet from registration
Examples Reading a portlet item, once in full once in shortform syntax:

portlet.item("name");
portlet.name



Registering a portlet from TMLScript:

var newPortlet = portlet.registerPortletForName("childPortlet", "myportletmodule");
newPortlet.setMode("edit");
newPortlet.setItem("key", KEY);
newPortlet.save();