I feel every application developer must understand the process flow and most importantly the script events ( i.e. On variable initialization, On Startup, and On Background Processing) before you start developing some real design studio applications.
On variable initialization:You can use this event to set query variables. If this event is used to set all mandatory variables, the variables will only be submitted once.
On Startup:This event is triggered only after on variable initialization and before On Background Processing
On Background Processing:You can use this event to load data sources in the background.
Below is the actual process flow:
- Initialize Data Sources
- Execute On variable initialization
- Show prompt dialog***
- Initialize Application
- Execute OnStartup
- Show prompt dialog***
- Render Components
- Trigger Background Processing
- Show prompt dialog***
- Render Components
***Displays prompt dialog if there are mandatory variables in the application without values, or if a variable is set to a wrong value.
Now lets take a simple scenario with 3 tabs, 3 crosstabs, and 3 different data source with mandatory variables, this is just to show how and when to trigger data sources.
Process flow 1: DS_1, DS_2, and DS_3 re all loaded during initialization
All 3 data sources have "load on script" as false.
- Initialize Data Sources DS_1, DS_2, and DS_3
- On variable initialization
- Mandatory variable check
- Initialize application
- Render Components
Total wait time to render: 6 sec
Process flow 2: DS_1 is loaded during initialization, and DS_2 and DS_3 on startup
Set DS_1 property
Set DS_2 and DS_3 property
"On Startup" Application property
- Initialize Data Sources (loaded DS_1)
- On variable initialization
- Mandatory variable check
- Initialize application
- On Startup (loaded DS_2 and DS_3)
- Mandatory variable check
- Render Components
Total wait time to render: 6 sec
Process flow 3: DS_1 is loaded during initialization, DS_2 and DS_3 on Background Processing
Now change the "On Startup" script to
and add DS_2 and DS_3 loading to "On Background Processing" event
-Initialize Data Sources (loaded DS_1)
- Initialize application
- On variable initialization
- Mandatory variable check
- On Startup (Trigger background processing)
- Render Components (TAB_1 loaded and visible)
- On Background processing (loading DS_2 and DS_3)
- Mandatory variable check
- Render Components TAB_2 and TAB_3 loaded in the background
Total wait time to render (initial screen): 2 secs
Best practice is to first load the screen/application which users will be viewing as soon as the application is displayed, and the other parts of the screen/application are loaded without being perceived as waiting time by the application user.
Now this again depends on the requirement, however try and get things done in background as much as you can.
Please go though some of the nicest blogs/documents on these events
- Dirk Mayrock's document on how to load data in sequence, i.e. say you want DS_3 to be loaded only after DS_2 is completed.
DS1.2 - Load Data in sequense - see data dropping in
- Martin Kolb's blog on "on Variable Initialization"
Design Studio: Performance Implications of Variables
- Tammy Powlas's document on "On Background Processing"