Input and Output Scope
Uniface provides a data scoping mechanism to control the data that is included in the execution of DSP triggers and operations, whether they are executed on the client or on the server. All data is blocked until the result of the trigger or operation is processed by the browser. While blocked, the data cannot be modified by the enduser (there is no point because it will be overwritten anyway). Any trigger or operation requests in the queue that use the same data are put on hold until the data is unblocked again.
In DSPs, triggers or operations can be executed on the server if they are defined with trigger or operation, or on the client if they are defined with webtrigger or weboperation. The Uniface data scoping mechanism applies to them all.
The data provided as input to the trigger or
operation is defined by the scope declaration using the keyword
input
. If input
is specified, all occurrences and field values of
the current DSP instance are provided as input to the trigger or operation.
The data that is returned by the trigger or
operation is defined by the scope declaration using the keyword
output
. If output
is specified, all occurrences, field values,
and properties returned by the trigger or operation are merged with the existing data. Occurrence
merging is based on occurrence IDs. Field values are simply overwritten, property values are
overwritten per property.
To explicitly specify the scope for a trigger or operation, use the scope and endscope statements to declare a scope block. The scope statement must follow a web statement. For example, use the following ProcScript in a trigger of a DSP field or operation:
; trigger Detail public web scope input ; all component data, except properties, is sent from browser to server output ; all component data, including properties, is returned from server to browser endscope ; Regular ProcScript here end
If no scope declaration is
specified, the scope default is used, which is the same as if input
and
output
are specified. You can use the scope block to:
- Exclude data from the trigger or operation execution, thereby reducing dependencies between multiple triggers and operations and allowing parallel processing.
- Reduce the amount of data sent from the browser
to the server or returned from the server to the browser. By leaving out the
input
statement, oroutput
you specify that no data is sent or returned, respectively. - Include data from multiple DSP components in the request-response exchange.
Combining Scope of Multiple Triggers and Operations
If you plan to activate multiple server-side
operations within a single server round trip, you can include the scope declarations of these
operations within the scope of the invoked trigger or operation. To do so, you need to reference
the scope block of an operation on another DSP instance using the
operation
option in the scope block. The referenced operation
must be defined as at least partner
web, which means it can be
referenced but not directly invoked.
Input and Output Scope
The following is an example of a master-detail construction.
The following ProcScript in the
detail trigger of a button displays more information about
the current item. The scope block includes an operation
parameter which references the scope block in the ShowDetails
operation of the MYDETAILS DSP instance.
trigger detail ; shows details if pressed public web scope input operation MYDETAILS.ShowDetails endscope webload reconnect/e "MYITEMS" websetocc newinstance "DETAILS", "MYDETAILS" activate "MYDETAILS".ShowDetails(ID.MYITEMS) end
- Trigger is fired from the browser when the
user presses the button, so it must be declared as
public web
. - Gather data from the browser, because it contains the item ID.
- Include data as specified in the
ShowDetails
operation of MYDETAILS DSP instance, which will return the details. - Load the received data.
- Reconnect the MYITEMS entity.
- Set the current occurrence content.
- Instantiate the instance.
- Note: There is no need to do a websave, because no data is returned for the component
The ProcScript of the
DETAILS.ShowDetails
operation specifies output scope, so it will return the
response:
operation ShowDetails ; of component DETAILS partner web scope output endscope params string pItemId : IN endparams ID.DETAILS/init = pItemId retrieve/e "DETAILS" websave end