Results 1 to 5 of 5

Thread: [Answers] Events sequence

  1. #1
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135

    [Answers] 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.



    All topics in [Answers] alphabetically: http://www.lianja.com/community/show...ll=1#post12352

    Last edited by josipradnik; 2015-04-27 at 05:12.

  2. #2
    Senior Member
    Join Date
    Jan 2014
    Posts
    351
    Hi Josip

    Thanks for the thorough explanation

    If my page has a form section with a child grid section and I need to update some control tables based on CRUD of child records, am I correct that I should put my update code in the "childgrid_changed" delegate or should it be in the "childgrid_datachanged" delegate?

    Your advice is much appreciated

    Thanks in advance

  3. #3
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Hi Tekhong,

    Not knowing exactly what you want to do, I can only point out the difference between these delegates:
    The dataChanged delegate is called whenever you finish editing a field or navigate between records.
    The Change delegate is called as you interactively edit fields.
    The "Data Changed" delegate is called whenever you navigate between records.
    The "Changed" delegate is called when you interactively edit data in a field on a form. if what you want is to verify that data entered and possibly popup a list of choices then that would better be placed as the validation in conjunction with auto suggestions.
    Datachanged is called when the "data" in the section changes. This occurs when navigating between records.
    This is true for all types of sections so even a webview, chart etc will cause the datachanged delegate to be called. It is not specific to records, it is specific to "data" thats why its called DataChanged.
    "Change"
    The delegate procedure for the Changed event. This is called when the Enter key or the Tab key are pressed.

    "Data Changed"
    The delegate procedure for the DataChanged event. This is called when navigating between records in a section.
    http://www.lianja.com/community/show...ull=1#post3315
    This discussion was about field but would be applicable to sections, I suppose.

    I am not sure if you want to update some 3rd table when editing child table record. (not sure what do you mean with "to update some control tables based on CRUD")
    If this distinction does not help you to decide, better you provide some little simulation app and upload it (I recommend making a package). Then we can all play with it and learn what others are doing.

  4. #4
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    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.



    All topics in [Answers] alphabetically: http://www.lianja.com/community/show...ll=1#post12352
    Last edited by josipradnik; 2016-04-07 at 02:47.

  5. #5
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    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.



    All topics in [Answers] alphabetically: http://www.lianja.com/community/show...p?2717-Answers

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us