OpenWGA 7.10 - OpenWGA Concepts and Features

Design and development » WebTML » Features » Actions

Ways of defining actions

The first step to provide a WebTML action for an application is defining it. This is the process of writing the process that should be executed on action triggering and optionally assigning it an ID for later referal.

Actions may be defined in three different ways:

Anonymous "In-Place" action:

This is a way of defining an action directly on a WebTML page, at the same place where an action link URL to call it should be created. The action is "anonymous" because it has no ID and is only callable via the action link URL that is generated.

This is done using WebTML tag <tml:url type="action"> while specifying the action code in the tag content:

<a href="<tml:url type="action">tmlform.storeInContent()</tml:url>">Store</a>

This directly creates an URL which will trigger the defined action when it is requested.

WebTML page action

The tag <tml:action> allows the definition of WebTML actions directly in WebTML code. The action gets the ID which is assigned to the tag on its mandatory id attribute. The action is available to the users session once the <tml:action> tag was rendered and will keep being so to the end of the session und less it is overwritten with the same id. 

However other features are needed to generate controls that actually call this action, like using <tml:url> with action attribute:

<tml:action id="myaction">


<a href="<tml:url action="myaction"/>">Store</a>

There are some ways to influence the way this action is executed by using some attributes of the <tml:action> tag:

  • master="true" lets the action code being run under master session rights.
  • async="true" decides if the action should run asynchronously, i.e. on calling the action the following page is rendered immediately while the action runs in parallel. The following page is then of course not able to react on the actions result.
  • debounce="false" can be used to switch off the otherwise mandatory "debouncing" for this action

This is a way of defining actions that does not force you to leave your WebTML environment for the definition, but has its downsides:

  • It is difficult to track used IDs for defined actions. Different WebTML pages may define equally named actions which - together with the session long persistence of action definitions - introduces the possibility of calling the wrong one
  • If URL definition and referal are not on the same WebTML module it sometimes is difficult to judge if the <tml:action> tag was already rendered and therefor if the action is available.
So the reasonable safe way of using this definition style is to have the definition on the same WebTML module that uses the action.

However we encourage WebTML designers to use the third way of definition instead:

TMLScript module action

Each TMLScript module in the OpenWGA design can be called as WebTML action. Calling the action executes the code contained in the TMLScript module.

The ID of an action defined as TMLScript module is just the design reference of that module. So it is the full path of the module file inside the "tmlscript" folder, where path dividers are replaced with colons ":" and the suffix of the module file is omitted.

Imagine a TMLScript module stored under "scripts/tmlscript/actions/ui/store.tmlscript" in some design directory, containing this code:;


This code called as action will store the data submitted with a TMLForm, then redirects the browser to the homepage.

On a WebTML page this TMLScript module may be called as action like this:



  <tml:button clickaction="actions:ui:store"/>


It is also possible to call a TMLScript module from another web application than the current one as action. Just prefix the action ID with the database key of the application, divided by a slash. So in an app with dbkey "main" this would be: 

  <tml:button clickaction="main/actions:ui:store"/>

You may also use Design Shortcuts for plugins instead of database keys here.

TMLScript modules are the recommended way of defining actions that need to be called from several places. As they are organized as files and their IDs are derived from their file names they are safe from multiple ID usage. It also is good programming practice to separate "controller code" from the "view code" which improves maintainability of both.

It is also possible to define a master/async/non-debounced action as TMLScript module. Just include the content of an <tml:action> tag, just like you would define it on a WebTML page, and use the needed attributes on it. Assure that the start /end tag are on the very first/last line without any extra characters for this to work:

<tml:action master="true">
var con = hdb().createStorage("newstorage");;

The otherwise mandatory id attribute for <tml:action> is not necessary here as the action id is already determined by the module file name.