Skip to main content
Version: 20 R10 BETA

WA SET CONTEXT

WA SET CONTEXT ( {* ;} object ; contextObj )

ParameterTypeDescription
*OperatorIf specified, object is an object name (string). If omitted, object is a variable.
objectanyObject name (if * is specified) or Variable (if * is omitted).
contextObjObjectObject containing the functions that can be called with 4ドルd.

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.

note

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ドルd has access to all 4D methods.
  • If contextObj is empty, 4ドルd has 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

WA Get context

Properties

Command number1848
Thread safe

AltStyle によって変換されたページ (->オリジナル) /