Declaration: | trigger postActivate
|
Applies to: | Component |
Activation: | Activated after the requested operation is activated, and in a web environment, before the preRequest trigger. |
Default behavior: | Sets return 0 |
Behavior upon completion: | None |
Description
The postActivate trigger is typically used to handle post processing specific to the operation, such as storing the state of a transaction, and so on.
State management is especially significant in a web environment, so default ProcScript is provided in the postActivate trigger of dynamic and static server pages.
Example: postActivate Trigger for DSP
The default code of the DSP postActivate trigger generates the initial page or a page updated, depending on the value of $webresponsetype. The following example shows a simplified version of this code (excluding the error handling.)
trigger postActivate selectcase $webresponsetype case "UPDATE" ; Update page websave ; Generate data case "FULLPAGE" ; Initial page weblayout ; Generate layout webdefinitions ; Generate component definitions websave ; Generate data endselectcase end; postActivate
Getting and Setting State with Cookies
The following example gets the Uniface cookie
from the browser and places it in the $cookie$
component variable. The USERCONTEXT
information is stored as an associative list in the format
Variable=
Value, where
Variable is the name of a field or variable in the server page. The
getlistitems/id
statement reads the values contained in
$cookie$
and distributes them accordingly:
trigger preActivate $cookies$ = $webinfo("USERCONTEXT") getlistitems/id/component $cookies$ end; preActivate
In the postActivate trigger of the static server page, the following code
updates the state information when the page completes. The ProcScript in this example initializes a
component variable $statelist$
with the names of the fields or variables
containing the state information, then uses the putlistitems/id
statement to populate the list in $statelist$
with the current values from the
server page:
trigger postActivate
$statelist$ = "Variable1=;Variable2="
putlistitems/id/component $statelist$
$webinfo("USERCONTEXT") = $statelist$
end; postActivate
If you put empty cookie data into the first item
of USERCONTEXT
, for instance, by using putitem
$statelist$, 1, ""
, followed by $webinfo("USERCONTEXT") =
$statelist$
, Uniface substitutes a NULL identifier at the moment the empty cookie data is
sent to the client.