function
Calls the specified function, evaluating the logic in it. The specified function may be defined within the template in which this command itself is in or in a separate Online template. There's also a set of global functions defined on the Dynamo server that may be called. Should there be functions bearing the same IDs in these three possible sources, functions in the separate template defined through the provider
attribute have the highest priority while global functions have the lowest.
Parameters to the function are supplied as a Map - an entry in the Map should have a parameter name as its key and the parameter value behind it. If a required parameter is not in the Map, or if a parameter's value is not of the type the function declares, the function call will fail.
The function
command cannot be used in functions. If evaluated within a function, this command only produces an error.
Attributes
id | ||
---|---|---|
Required | Value type | EL-evaluated |
Yes | String | Yes |
Defines the ID of the function to call. |
var | ||
---|---|---|
Required | Value type | EL-evaluated |
Yes | String | No |
Defines the name of the variable that will hold the called function's return value. If the function returns nothing, the variable will still be created but its value will be |
parameters | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Map | Yes |
Defines the parameters delivered to the function. Keys and their values in the Map should be parameter names and their values, respectively. The Map may also contain entries that are not parameters recognized by the function - the function will most likely just ignore them. If not defined, the function receives no parameter values and should it have required parameters, the call will inevitably fail. |
provider | ||
---|---|---|
Required | Value type | EL-evaluated |
No | File | Yes |
Defines an Online template expected to contain the function to be called. If the resolved value is a File but not an Online template, an error is generated. |
Examples
This command itself doesn't do anything particularly complicated, as the functions themselves are the focus. The setMap command can be used to construct the parameters Map. Be sure to provide parameters of the correct type - if a function requires a Collection as a parameter value, providing something else like a String as that parameter value instead generates an error and the function call fails.
<setMap var="params"><addMapEntry key="fileID" value="${imageID}"><function id="loadFile" var="image" parameters="${params}"/>