Binding Processing Sessions

Top  Previous  Next

All bindings in the widget are processed in special sessions. There are several types of binding processing sessions:

Startup session. In this session, every binding that has the On startup flag enabled is processed.
Periodic session. This session always includes only one binding for processing - the one that has Periodically flag enabled. It starts after every Evaluation Period of this binding.

note_further-wt

Even if several bindings have the same evaluation period, they are processed separately, in rapid succession (one right after the other). For technical reasons, they're not grouped.

Event session. This type of session is possible only for bindings that have the On event flag enabled. If a binding's Activator refers to an event, the binding will be processed when the event fires. If On event is enabled and an Activator is not specified, the binding will be automatically processed: The binding's Expression includes references, pointing to one or more values. A change in any of these values will cause the binding to run. When the widget engine detects it's time run a binding processing session, it scans to see which other bindings must participate in the session.

Only bindings that have their On event flag enabled may be included in the session. The following bindings are included into one session:
 
1. Every binding whose Activator is the same as the reference which caused the session to run.
 
2. Every binding which has no Activator and whose Expression includes the reference which caused the session to run.

To recapitulate, before running a binding session, AggreGate Server first finds all bindings which will participate in it.

AggreGate Server groups all bindings participating in a given session. Each binding is not processed separately, but may affect processing of other bindings within the same session.

Within a single session, bindings are processed in a certain order, depending on their targets (see Processing Precedence). When a binding is processed, its Expression is evaluated and its result is written to the Target.

The Target expects a value of a certain type (e.g, an integer), so the Expression must indeed evaluate to that type -- otherwise the binding won't process correctly (try putting a string value into a field which needs an integer -- it won't work).

Any errors during binding processing are shown using the Show Error UI Procedure:

ls_widgets_binding_error

Context Data Caching

Values of context variables and output values of context functions are cached during a binding processing session. When the processing engine resolves a standard reference pointing to a certain field and gets its value, the Data Table containing this value will be cached in session data. If there's another reference to the same variable (even if it refers to another field within that variable) it'll be retrieved from the cache.

The same applies for context functions. If there are several references pointing to various output fields of a function, the function will be called just once in the session. Other references to its output will be resolved through the cache.

Processing Precedence

Within a given session, bindings are processed according to their targets.

1. Bindings to function input fields

Bindings whose targets point to an input field of a function are processed first. The expressions of such bindings are evaluated and resulting values are used to fill the input Data Table of the function before it is called. The actual function call is performed during processing of bindings those target point to context functions itself (see next step).

2. Bindings to context functions

At this step, bindings pointing to context functions are processed. When such a binding is processed, function is called with parameters collected at the previous step.

3. Bindings to fields of variables

Bindings to the fields of context variables are processed next. Several steps are performed for every variable:

The variable's value is retrieved from the AggreGate Server context and cached in session data
All bindings to the fields of this variable are processed, their expressions evaluated and evaluation result stored in the corresponding field of the variable value
The Data Table containing the modified variable value is written back to the source context

4. Bindings to variables

Expressions of bindings whose target points to the value of a variable (and not a certain field within it) are now evaluated. The evaluation of each such expression must result in a Data Table. Assuming this Data Table has the same format as the variable, it now replaces the variable value.

5. Bindings to widget component properties

Bindings to properties of widget components are the last to be processed. The target points to a component property, and this property is now set to the result of the binding expression evaluation.