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, or output 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 partnerweb, 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    Callout 1 
scope
  input   Callout 2 
  operation MYDETAILS.ShowDetails   Callout 3 
                                        
endscope
  webload   Callout 4 
  reconnect/e "MYITEMS"   Callout 5 
  websetocc  Callout 6 
  newinstance "DETAILS", "MYDETAILS"  Callout 7
  activate "MYDETAILS".ShowDetails(ID.MYITEMS) Callout 8  
end
  1.  Trigger is fired from the browser when the user presses the button, so it must be declared as public web.
  2.  Gather data from the browser, because it contains the item ID.
  3.  Include data as specified in the ShowDetails operation of MYDETAILS DSP instance, which will return the details.
  4.  Load the received data.
  5.  Reconnect the MYITEMS entity.
  6.  Set the current occurrence content.
  7.  Instantiate the instance.
  8.   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    Callout 2.1 
scope
  output   Callout 2.2
endscope
params
  string pItemId : IN   Callout 2.3 
endparams
  ID.DETAILS/init = pItemId
  retrieve/e "DETAILS"
  websave    Callout 2.4  
end
  1.  The operation can only be called by Uniface, not directly by the browser, so it must be declared as partner web.
  2.  This component returns the details of an item.
  3.  Regular IN parameters.
  4.  Generate a response.

Related Topics