OpenWGA 7.10 - JavaScript reference

WGA
Method :

WGA.action(paramObject)

On object WGA
Usage Calls a normal (non-AJAX) WebTML Action from clientside Javascript
Description Use this function if you want to trigger the execution of a serverside WebTML action from clientside code.

The method takes a single param object containing all the settings to call the action as properties, the most important one being the "action" property containing an action link to be generated via <tml:action ref="actionid"/>. It determines the action to call plus the WebTML action parameters that this call sends.

Optionally the call can also be provided with URL parameters in the "params" property, which have the advantage over action parameters to be determinable on the client side by the JavaScript itself. All values on this params 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.
Parameters

paramObject (JavaScript object):

The parameters for this action call. The object may carry the following properties:

  • action (String): The action link generated by <tml:action ref="actionID"/>
  • params (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. Parameter values are automatically encoded in UTF-8, so using this OpenWGA output encoding is strongly encouraged when using this functionality with non-ASCII text values.
Examples

A simple usage of WGA.action() in client side JavaScript, properly formatted to identify the elements of the call (which is not necessary syntax-wise):

<script>

WGA.action(

  {

    action:'<tml:action ref="saveDocument" param1="true"/>',

    params: { title: 'New Document', lang:'de' }

  }

);

</script>

Notice the string delimiters around <tml:action> which are necessary for this to work. They enclose the action link string generated by <tml:action>.

The properties of the "params" object will get passed to the call as URL parameters like following: ?title=New%20Document&lang=de.