OpenWGA 7.10 - 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 should be given by the attribute "onevent".

If a portlet subscribes to an event it will be automatically reloaded if the event is thrown (via AJAX if this is not disabled). It then can react with calling a WebTML action specified by attribute action and/or with a normal script, contained in this tags body, which is run while the tag is re-rendered with the portlet (just like on a regular <tml:script> tag).
Derived from: Attributes:
show inherited attributes ...
Name Value(s) Purpose
action action-id Determines the action to run when the event occurs
onevent event-name Defines the name of the event which the portlet should subscribe to

Details:

Both, WebTML action and the script inside the body of this portlet, are provided a variable named portletEvent, which contains the PortletEvent object representing the event thrown.

A script in the tag content could also 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 reload the page.
Examples:
Listens to a Portlet-Event without using a script. The Portlet gets reloaded if the event is thrown:

<tml:eventscript onevent="update"/>


Listens to a Portlet-Event and calls an action of ID "updateView". Then portlet changes its mode to "view" and gets reloaded:

<tml:eventscript onevent="saved" action="updateView" portletmode="view"/>


Listens to a Portlet-Events and evaluates a parameter:

<tml:eventscript onevent="myEvent">

   

    portlet.setitem("eventParameter", portletEvent.getParameter("myParam"));

    portlet.save();


</tml:eventscript>


"Portlet constructor" 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>