OpenWGA 7.10 - JavaScript reference

Method :

WGA.callAction(actionLink [, urlParams])

On object WGA
Usage Calls a normal (non-AJAX) WebTML Action from clientside Javascript

This is a convenience method for WGA.action() for triggering serverside WebTML actions offering the most frequently used parameters as arguments.

The method takes an action link as a string parameter. This action link needs to be generated by WebTML tag <tml:action ref="action-id"/>. The attributes on this tag determine the action to call plus all additional WebTML action parameters and settings of the call. As the <tml:action> tag does not generate string delimiters you need to specify them yourself in the Javascript code.

Optionally the call can also be provided with URL parameters in the "urlParams" argument, which have the advantage over action parameters to be determinable on the client side by the JavaScript itself. All values on this urlParams object will get converted to strings when they are converted to URL parameters. The WebTML action code can retrieve these parameters using method this.request.getParameter(paramName).

After WGA.callAction() is called the current HTML page will get reloaded to execute the action. So the Javascript code after this call will not be effective for the page that is now loaded.


actionLink (String):

An action link string to be generated by <tml:action>.

urlParams (JavaScript object, optional):

An object whose properties are to be used as URL parameters on the action call, using property name as parameter name and property value as parameter value. Specifying multi-value parameters is not supported.


A simple usage of WGA.callAction() from an HTML button:

<button onclick="WGA.callAction('<tml:action ref="saveDocument" param1="true"/>'); return false;">Save me!</button>

Notice the string delimiters around <tml:action> which are neccessary for this to work. They enclose the action link string generated by <tml:action>. Also, although code after WGA.callAction() is not effective for the page that gets loaded it is a good idea to end the event script with "return false" to keep the event from further "bubbling up".

By the way: Simple buttons to call action links are generated way more easily using <tml:button>.