WA SET CONTEXT
WA SET CONTEXT ( {* ;} object ; contextObj )
Parâmetro | Tipo | Descrição | |
---|---|---|---|
* | Operador | → | Se especificado, object é um nome de objeto (string). If omitted, object is a variable. |
object | Objecto de formulário | → | Nome do objeto (se * for especificado) ou Variável (se * for omitido). |
contextObj | Object | → | Object containing the functions that can be called with $4d . |
Descrição
The WA SET CONTEXT
command defines a context object contextObj for $4d
in the Web area designated by the * and object parameters. When this command is used, $4d
can only access contents declared within the provided contextObj. When no context object is set, $4d
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 $4d
as objects. Class functions that begin with _
are considered hidden and cannot be used with $4d
.
- If contextObj is null,
$4d
has access to all 4D methods. - Se contextObj estiver vazio,
$4d
não terá acesso.
Exemplo 1
Permitir $4d
a métodos específicos
var $context:={}
$context.myMethod:=Formula(myMethod)
$context.myMethod2:=Formula(myMethod2)
WA SET CONTEXT(*; "myWebArea"; $context)
Em JavaScript:
$4d.myMethod(); // Permitiu
$4d.myMethod2(); // Permitiu
$4d.someOtherMethod(); // Não acessível
Exemplo 2
Using a Class Object
var $myWAObject:=cs.WAFunctions.new()
WA SET CONTEXT(*; "MyWA"; $myWAObject)
Em JavaScript:
$4d.myWAFunction(); // Permitido
$4d._myPrivateFunction(); // Não fará nada porque a função é privada
Veja também
Propriedades
Número de comando | 1848 |
Thread safe | ✗ |