Skip to main content
Version: Next

WA Run offscreen area

WA Run offscreen area ( parameters ) -> Function result

ParameterTypeDescription
parametersObject🡒Object containing the web area's attributes
Function resultMixed🡐.result property of the onEvent object, or Null if does not return a value

Description

The WA Run offscreen area command creates a web area in memory which can be used to automatically load and parse web pages.

Note: This command uses the embedded web rendering engine.

In parameters object, pass any of the following optional properties. These properties will be available through the This command within the onEvent method and reference the instance:

PropertyTypeDescription
urltext | file objectThe URL or file to be loaded in the web area. If omitted or null, a blank page is loaded.
areatextThe name of the web area. If omitted or null, a generic name is assigned (e.g., OffscreenArea1).
onEventobject (formula)A callback method that will be launched when the web area is ready. It can be either:
an onEvent function of a class, or a Formula object By default, the callback method is called on the On Load, On Unload, On End URL Loading, On URL Loading Error, or On Timer events.
autoQuitbooleanTrue (default value) if the command must stop the formula execution when the On End URL Loading or On URL Loading Error events occur.

If false, you must use the CANCEL or ACCEPT commands in the callback method or project methods called with the $4d object to close the web area.
timeoutrealMaximum time (expressed in seconds) before the area automatically closes if no event is generated. If set to 0, no limitation is applied. Default value: 60
resultmixedResult of the processing to be returned (if any)
mixedAny custom attribute to be available in the callback or $4d method.

The following property is automatically added by the command if necessary:

PropertyTypeDescription
timeoutReachedbooleanAdded with true value if timeout has been exceeded

If a null value is passed in parameters, a blank web area will be created and then automatically closed.

Notes:

  • The offscreen web area is only available during the execution of the WA Run offscreen area command. It will automatically be destroyed once execution has ended.
  • 4D methods can be called from the JavaScript code executed in a web area. See Accessing 4D methods.

The following commands can be used in the callback method:

Example

You want to create and handle an offscreen web area using a function of your OffscreenArea class:

 $config:=cs.OffscreenArea.new()
 $result:=WA Run offscreen area($config)
 If($config.timeoutReached) //automatically returned in case of timeout
    ALERT("Timeout reached")
 End if

In the OffscreenArea class:

 Class constructor
 This.url:=File("/RESOURCES/compute.html")
 This.area:="myWAOffscreen"
 
 Function onEvent
 Case of
    :(FORM Event.code=On End URL Loading)
       This.result:=WA Evaluate JavaScript(*;This.area;"myJSMethod();")
 End case

System variables and sets

The OK system variable is set to 0 if the timeout has been reached or the CANCEL was called in onEvent, otherwise it is set to 1.

See also

FORM Event
Programmed management of Web Areas
WA OPEN WEB INSPECTOR