WA SET CONTEXT
WA SET CONTEXT ( * ; object : Text ; contextObj : Object )
WA SET CONTEXT ( object : Variable, Field ; contextObj : Object )
| Parameter | Type | Description | |
|---|---|---|---|
| * | Operator | → | If specified, object is an object name (string). If omitted, object is a variable. |
| object | Text, Variable, Field | → | Object name (if * is specified) or Variable or field (if * is omitted) |
| contextObj | Object | → | Object containing the functions that can be called with 4ドルd. |
History
| Release | Changes |
|---|---|
| 20 R9 | Added |
Description
The WA SET CONTEXT command defines a context object contextObj for 4ドルd in the Web area designated by the * and object parameters. When this command is used, 4ドルd can only access contents declared within the provided contextObj. When no context object is set, 4ドルd has access to all 4D methods and can not access user classes.
The command is only usable with an embedded web area where the Use embedded web rendering engine and Access 4D methods parameters are set to true.
Pass in contextObj user class instances or formulas to be allowed in 4ドルd as objects. Class functions that begin with _ are considered hidden and cannot be used with 4ドルd.
- If contextObj is null,
4ドルdhas access to all 4D methods. - If contextObj is empty,
4ドルdhas no access.
Example 1
Allow 4ドルd to specific methods
var $context:={}
$context.myMethod:=Formula(myMethod)
$context.myMethod2:=Formula(myMethod2)
WA SET CONTEXT(*; "myWebArea"; $context)
In JavaScript:
4ドルd.myMethod();// Allowed
4ドルd.myMethod2();// Allowed
4ドルd.someOtherMethod();// Not accessible
Example 2
Using a Class Object
var $myWAObject:=cs.WAFunctions.new()
WA SET CONTEXT(*; "MyWA"; $myWAObject)
In JavaScript:
4ドルd.myWAFunction();// Allowed
4ドルd._myPrivateFunction();// Will do nothing because function is private
See also
Properties
| Command number | 1848 |
| Thread safe | no |