OpenWGA 5.4 - WebTML reference

WebTML tags

<tml:eventscript>

Description :
This tag adds the current portlet  to the listeners of a portlet event. The name of the event , which the portlet will be added to, can be given by the attribute "onevent".

If a portlet listens to an event it will be automatically reloaded if the event occurs. The body of <tml:eventscript> can contain a script which gets executed in this case. In this way the portlet is able to react on the catched event.
Derived from: Attributes:
show inherited attributes ...
Name Value(s) Purpose
ajax true|false|t|f|0|1
Determines if a Portlet should get reloaded by ajax if an event was thrown.
onevent Event-Name Defines the name of the event which should listen to.
portletmode Portlet-mode This attribute sets the portletmode after an event was caught.

Details:
TML-Script-code which is defined in the body of the eventscript tag contains additional objects:

With this tag it is possible to react to the predefined event named "init". This event is triggered if the portlet is displayed for the current user at the first time and can be used as "constructor" to initialize the portlet. Unlike other events "init" does not reaload the page.

portletEvent:

An object from type PortletEvent, witch contains  extra information to the thrown event. This object represents the last thrown event if several events has been thrown at the same time.

portletEvents:
A list of all PortletEvent-objects thrown at the same time. Usually there is only one event thrown so the list has only one entry.
The execution of an event-script is similar to the execution of a <tml:script> tag, apart of the additional objects. It will NOT be executed as WebTML-action!

This means: The execution of the scripts is located exactly at the position of the eventscript tag and can access to all WebTML tags and variables available  at this position like a script in a <tml:script> tag would do.
Examples:
Listens to a Portlet-Event without using a script. The Portlet gets reloaded if the event is thrown:
<tml:eventscript onevent="update" ajax="true"/>

Listens to a Portlet-Event without using a script. The Portlet changes its mode to "view" and gets reloaded:
<tml:eventscript onevent="saved" ajax="true" portletmode="view"/>

Listens to a Portlet-Events and evaluates a parameter:
<tml:eventscript onevent="myEvent" ajax="true">
   
    portlet.setitem("eventParameter", portletEvent.getParameter("myParam"));
    portlet.save();

</tml:eventscript>



"Portlet-construktor" with event "init". The creation timestamp is saved in the Portlet-configuration:
<tml:eventscript onevent="init">

    log.info("Initialisation of portlet");
    portlet.setitem("inited", createDate());
    portlet.save();

</tml:eventscript>