How often events fire and their sequence
Some events fire more often than others. Depending on what the designer is trying to achieve, this can be inefficient and may not have the desired effect at runtime. Another issue is the sequence in which events fire. A designer may have a requirement for several scripts to fire in a certain sequence. Having an understanding of how LC Designer and Acrobat fire events can help at design time.
I original had the idea of having a form that set out the pros and cons of each event and giving examples of script that could be used in each event. In the end, it has focused on the number of times that different events fire and the sequence. To view this form you will need Acrobat/Reader version 9 or above. This is because it contains script against the preOpen and postOpen events. Also it used setItems to populate the listbox.
The attached form has a lead-in page to introduce the different types of events and how to use the form.
The second page contains the “test area”, which is where you can decide which objects you are going to look at, via the dropdown list. There are textfields, numericfields, buttons, subforms, dropdown lists, etc. Some of the objects are standalone, while others are bound together. For example a textfield will have the following in the calculate event:
this.rawValue = textField2.rawValue;
Below the test area are counters for the three types of events (Process; Interactive; and Application). These show how often each event fires.
You can show and hide the different types of events, for example if you want to focus on a particular group.
Even though there are other objects in the form, only those in the test area are counted, as events fire.
All of the objects in the test area have scripts in each event. Generally these script are triggering the counters; however a couple are also binding objects together. This is useful in demonstrating the firing of calculate and validate events for objects that are bound.
There is a log showing the sequence in which the events have fired. When you go into the test area the log with automatically hide. Clicking the show button will make it visible again. Note that clicking the hide button will also clear the log.
There were quite a few challenges in developing this:
- The calculate; validate; and layout:ready events were bound by the counters. So it took several attempts to separate out the calculate event and validate event from the counters, so that they did not run away with themselves. In the end we broadcast the counter value out and the objects are not linked;
- Getting the log to record the events as they fired and have the most recent events visible at the bottom of the log. We used the new setItems script to populate the listbox with a global variable.
The form has some “interesting” script, but not much that has purpose in a real world form.
It is more of a point of interest to look at the interaction of events and how often some events like layout:ready fire.
The sample form is available here: Assure Dynamics LiveCycle Designer Script Events
[...] layout:ready event Posted in: ADEP, LiveCycle- Oct 16, 2011 No Comments A previous post show how events fired and their sequence as a user interacted with your form. If you explore the [...]