Events sequence

Q:
I navigate to a different page using Lianja.activePage = page2 & the new page opens just fine.
I want to do some things when the page loads (move to a desired record or start add mode etc.). A few questions:

– I did some tests and page load/init/ready all fire when the app starts and never again, am I right in assuming that all pages load up at the start of the app?
– What event could I use to setup a page when navigating to it as above?
A:
Events are called in the order init, load, ready and then activate for the active Page/Section.
When you navigate to a Page, its activate event is called.



In Lianja v2.1 when the
App Inspector is active, events are logged in the “Events” tab in both development view and runtime view.
In versions prior to v2.1 the events were only logged in runtime view. This provides more useful information when optimizing the speed of an App.


The object is available in the READY event, which fires before the Activate, so you should be able to access it there also if you have a need.


Q:
I think it’s better to indicate in which event additems method can be used to load initial value in the list or combo item when the app starts.
A:
Use the ‘ready’ event. During development in the Lianja App Builder, the ‘ready’ event is called when the App is loaded, so just save and reload the App to force the ‘ready’ event to be called and see your new code.



Events sequence

Try it with a command that does not change the focus – valid() is called before the control has lost focus. e.g. instead of messageBox(“…”) or wait window “…”
Lianja.writeLog(“…”)


Q:
where I should place the code to initially disable some of the buttons in canvass section upon running/opening the project?
A:
In the section “Ready” delegate.


Q:
Is it possible to change the textbox input mask based on the selected combo box value?
This doesn’t seem to work in the Web App View.

Code:
function client_secsearch_cbosearchwhat_interactivechange()
{
        switch (upper(cbosearchwhat.text))
        {
            case "CLIENT NUMBER (XX####)":
                txtsearch.inputmask = "^^9999";
                break;
            case "PHONE (##########)":
                txtsearch.inputmask = "9999999999";
                break;
            case "ADDRESS":
            case "CLIENT NAME":
                txtsearch.inputmask = replicate("!",30);
                break; 
        }       
};

When the web app view is loaded, the input mask remains the same as the last reference used in the pages workspace.
A:
Try using the ‘Change’ (changed()) delegate instead of ‘Interactive Change‘.


The events are called in the order:
“init”,
“load”,
“ready”,
“activate”
from the App: (mnemonic help:
ILRA)

App
– First Page
– First Section of the first Page
— The Fields the first Section
– Section II of the first Page
— The Fields of the second Section
– …
— …
– Second Page
– …
— …

If a variable is required for particular component would normally be declared / initialized in the “init” or “init” earlier in the hierarchy.
The database is available for events of “load“.
For visual properties, such as section.collapse (), wait for the internal load and display have been completed – put them in the “ready” event for the component.



Events sequence

The Class type is important here. If you have a VFP Custom class – e.g. you are running an imported scx as an scp – then the order is as Cyril says and load comes first (more here).
If you are talking about the Lianja Object Model (LOM): Pages, Sections, Fields/Gadgets etc. then load follows init.



Q: 
Lianja where it’s start ?
A:
first Page in the App is the starting point in terms of display. Prior to this, the setup.prg (if exists) will be run, the init, load and ready events will be run (http://www.lianja.com/community/show…ence-of-events) along with any database open event / table open trigger scripts. The first visible Page is also dependent on Page read roles (http://www.lianja.com/community/show…ence-of-events) – the user will see the first Page they have permission to ‘read’.



Q: 
Which event is best suited for deinitializing variables / setting flags etc?
A: 
Destroy comes last after Unload – Page1 Unload, Page1 Destroy, Page2 Unload, Page2 Destroy, … , App Unload, App Destroy. Public variables are released and the database is closed after the App Destroy delegate has run.



The events are called in that order: init, load, ready, activate with the App first:
App
– first Page 
— first Page’s first Section
— first Section’s Fields
— first Page’s second Section
— second Section’s fields
— … 
— …
– second Page
— …
— …
If a variable is required by a particular component it would normally be declared/initialised in its init or the init earlier in the hierarchy. The database is available to the load events. For visual properties, such as the section.collapse(), wait until the internal loading and display have completed – put them in the ready event for the component.



The ‘Change’ (xxx_changed()) delegate is called when a record is modified – after ‘After Data Update’ (xxx_afterupdate()).
The ‘After Data Changed’ (xxx_datachanged()) delegate is called on Form Sections after the data is read – as you move through the records.