call
Calls a JavaScript function through the web component.
Syntax
ui.Interface.frontCall("webcomponent", "call",
[aui-name, function-name [, param1, param2, ... ] ],
[result]
)
- aui-name - This is the name of the web component name in the AUI tree.
- function-name - This is the name of the web component JavaScript function to be called.
- param1, param2, ... - Optional parameters to be passed to the web component JavaScript function.
- result - Holds the JavaScript function return value.
Usage
This front call executes a JavaScript function of the WEBCOMPONENT
form field
identified by aui-name.
The JavaScript function identified by function-name must be implemented in the HTML content pointed by the URL-based web component, or in the user-defined JavaScript of a gICAPI-based web component.
The arguments following the function-name argument will be passed to the JavaScript function.
The result variable will contain the value returned by the JavaScript function.
When using simple data types in arguments, values are passed as is to the JavaScript function of
the web component. When using RECORD
or DYNAMIC ARRAY
types, the
runtime system converts the structured data to a JSON string. Similarly, if the JavaScript function
returns a complex data structure in JSON notation, it must be used to assign a
RECORD
or DYNAMIC ARRAY
.
For more details about JSON notation usage for complex data types, see the ui.Interface.frontCall()
method.
Example 1: Using a simple string parameter and return value:
DEFINE result STRING
CALL ui.Interface.frontCall("webcomponent","call",
["formonly.mywebcomp","echoString","abcdef"],[result])
Example 2: Using structured variables to be converted to JSON for the JavaScript code:
DEFINE options RECORD
filter STRING,
creation DATE
END RECORD,
items DYNAMIC ARRAY OF STRING
LET options.filter = "abc*"
LET options.creation = TODAY
CALL ui.Interface.frontCall("webcomponent","call",
["formonly.mywebcomp","getItems", options ],
[ items ])
For a complete example, see Example 1: Calling a JavaScript function.