webactivate
Sends an instruction to the browser to invoke an operation.
webactivate InstanceName{.
OperationName
{(
Parameters)
} }
Example: webactivate $instanceName.setTheme()
Parameters
Parameter | Data Type | Description |
---|---|---|
InstanceName | String | Name of a component instance that holds the definition for the requested operation; maximum length of 16 bytes. |
OperationName | String | Literal name of an operation that is part
of the specified component instance, or a variable containing the name of an operation as a string.
Other valid values are EXEC , ACCEPT , or QUIT . If no operation and arguments are
specified, |
Parameters | String | Optional IN parameters |
Return Values
The output of webactivate is an
instruction to the browser, with specified instance name and operation name, and it will be put in
the $webinfo("data")
channel.
Value | Description |
---|---|
0
|
Executed successfully |
< 0 |
An error occurred. $procerror contains the exact error. |
Use
Allowed in all component types.
webactivate can only activate operations in Dynamic Server Page components.
Description
At runtime, the webactivate
statement adds an activate
instruction to the web output sent to the browser. (If
the webactivate command is initiated by an HTTP request from a DSP page on the
browser, the generated instruction is merged into the HTTP response.)
The browser loads or updates the DSP (and any child DSPs associated with DspContainer widgets) based on the data in the HTTP response, and then executes the generated instruction, thereby calling the specified operation. The operation itself can be implemented as JavaScript on the client, in which case it is executed by the browser, or as ProcScript on the server. In this case, the browser posts an HTTP asynchronous request to the Uniface Server to activate the specified operation.
Activating Client-Side Operations
Client-side operations are intended to reduce the round-trip calls between client and server, so it may seem unusual that the server should invoke a client-side operation. However, this can be useful in cases where the server requires additional information from the client (or example, for conditional navigation) or to give the browser a chance to aggregate operation calls after different requests to the server.
Client-side operations are subject to scoping rules, so execution of the operation called by webactivate may be postponed if its input or output is blocked. For more information, see Input and Output Scope.
If there are several webactivate statements invoked in one HTTP request, they are executed in the supplied order.
Conditional Page Navigation Request
Full page navigation must be initiated from the browser; it is not possible for the server to respond to an AJAX update request with a full page. If the browser requests an update, the server must (always) respond with a full page.
However, it may not be known in advance if a page update is required. For example, a web page has a Next Page button which stores data first and then, if the store is successful, instructs the browser to navigate to the next page. If the store fails, it simply displays a message with the error. All state on the browser is still there, enabling the enduser to try again.
In this example, webactivate calls an operation that has a JavaScript implementation and will be executed on the browser. The JavaScript simply loads a new URL.
detail trigger of a Next Page button in a DSP:
trigger detail ; Next Page button public web scope input output ; include URL field ; Remark: Do not specify operation <$componentname>.GotoURL endscope store/e entity if ($status < 0) webmessage/error "Store error ($status = %%$status%%%), page navigation canceled" else URL = "http://localhost:8080/uniface/wrd/run/next_dsp" webactivate $instanceName.GotoURL() endif return 0 end
GoToURL operation:
weboperation GotoURL scope ; nothing endscope javascript { // ; instruct Uniface to execute this operation on the browser // ; JavaScript begins here // ; ... <snip> Javascript to establish context (instance, entity, occurrence, field) </snip> // ; some JavaScript to invoke new page; for example: window.location = uniface.getField("URL").getValue(); //the value should be "../next_dsp" } endjavascript end
Version |
Change |
---|---|
9.5.01 |
Introduced |