This section discusses when to use the same trigger at multiple levels and how to override the default scope of a trigger by making it fire more than once. Examples are provided in the appropriate subsections as to when it is required to follow each method.
Using the Same Trigger at Multiple Levels
There are many situations in Forms when it is required to use the same trigger at multiple levels. The knack behind this is to use the same trigger at multiple levels if the trigger has to behave differently at any one level, for the same triggering event.
A quick example is the behavior of the KEY-NEXT-ITEM trigger for tabbing in a block. This is a requirement when groups of items are in a single-record control block and no two groups are similar functionally. A good example is an input parameter screen for a list of reports in which different parameters are grouped per report (and might be placed in different canvases). So there should not be any tabbing between two dissimilar groups. Also, think of the situation in which items in each group are in different canvases. One way to do this is to write KEY-NEXT-ITEM triggers: one at the block level, which nullifies the action, and one each for the first and last items in each group that enables tabbing.
Also, we do not write the KEY-NEXT-ITEM trigger for the remaining items in the block, assuming normal tabbing between them.
The KEY-NEXT-ITEM at block level fires while navigating between those items that do not have an item-level trigger attached to them. The KEY-NEXT-ITEM for the item level fires for the first and last items of each group. In the second case, the block-level trigger does not fire as the lower-level trigger always fires, by default.
Of course, using the properties Next Navigation Item and Previous Navigation Item would have done the same job, but keeping in mind a situation like the one previously described, it is best to handle the navigation using triggers rather than relying on default Forms functionality. The code for the two triggers previously described is as follows :
KEY-NEXT-ITEM at block level NULL; KEY-NEXT-ITEM at Item level NEXT_ITEM;
The example of programmatically simulating a Cancel Query when in Enter-Query mode, as described in the previous section, suggests the behavior of the same trigger in two different ways in response to two different triggering events, exiting the form and coming out of Enter-Query mode. In this case, KEY-EXIT is fired when both these events are triggered.
Making the Same Trigger Fire at Multiple Levels More Than Once
The technique previously described involves the same trigger fire at two different levels by defining two instances of it. Now the question arises as to how to make it fire more than once at different levels. The default trigger that fires is the one at the lowest level.
To make the same trigger fire at multiple levels, set the trigger Execute Style property to Before or After to override the default trigger firing functionality. Then the same trigger can be made to fire more than once at different levels. (Note that the Execute Style property can be set only in the property palette of the corresponding trigger and cannot be set dynamically.)
A good example of this is pointed out in the preceding subsection, defining a KEY-NEXT-ITEM trigger, one at block level and one at item level. Here, the Execute Style property for the item level trigger is set to Before so that it fires first before the block level KEY-NEXT-ITEM trigger.
Advanced GUI Development: Developing Beyond GUI
Advanced Forms Programming
Object-oriented Methods in Forms
Intelligence in Forms
Additional Interesting Techniques
Working with Trees
Oracle 8 and 8i Features in Forms Developer