Four Js Development Tools Forum

Discussions by product => Genero BDL => Topic started by: Gary Collis on May 01, 2017, 12:51:10 PM

Title: Construct Question
Post by: Gary Collis on May 01, 2017, 12:51:10 PM
Hello

I have a need to initialise the form values when using a construct statement, in essence "remembering" the users previous search criteria when entering the dialog.

Is this possible? I know I can read the field values but I am struggling to see how to set them.

Thanks
Title: Re: Construct Question
Post by: Andrea Löhr on May 02, 2017, 11:13:35 AM
Hello

in our applications we automatically save the construct values in a table and offer the user a button to restore the last saved values.

In AFTER CONSTRUCT we use the AUI Tree to find all elements that were part of the CONSTRUCT with SelectByPath("//*[@dialogType=\"Construct\"]")
and search their Attributes "name" and "value" with getAttribute("name")  and getAttribute("value"). 

If the user press the Button for "RestoreValues" we also use the AUI-Tree with the same SelectByPath and set the Attribute "value" with
setAttribute("value") with the saved contents for all contruct fields.
Title: Re: Construct Question
Post by: Andrea Löhr on May 02, 2017, 12:23:43 PM
Hello again

I don't know if you are familiy with AUI Tree. Attached please find the modified demo program Field.4gl and Field1.per to show
how you can get and restore the construct values.
Hope it helps.
Title: Re: Construct Question
Post by: Reuben Barclay on May 02, 2017, 01:56:00 PM
I like Andreas generic code.

The methods ui.Dialog.setFieldValue http://4js.com/online_documentation/fjs-fgl-manual-html/#c_fgl_ClassDialog_setFieldValue.html and ui.Dialog.getFieldValue http://4js.com/online_documentation/fjs-fgl-manual-html/#c_fgl_ClassDialog_getFieldValue.html introduced in 3.00 could be used instead of the AUI tree reading and writing and would be safer in the long run.

If you don't want to go down the generic code path then DISPLAY will do what you were after ...

Code (genero) Select
        CONSTRUCT BY NAME where_clause ON field1, field2, field3
        BEFORE CONSTRUCT
            DISPLAY ">0" TO field1
            CALL DIALOG.setFieldValue("field2", "A*")

        AFTER CONSTRUCT
            IF int_flag THEN
                EXIT CONSTRUCT
            END IF
            DISPLAY "Field 1 = ", GET_FLDBUF(field1)
            DISPLAY "Field 2 = ", DIALOG.getFieldValue("field2")
    END CONSTRUCT
    DISPLAY where_clause

Title: Re: Construct Question
Post by: Gary Collis on May 03, 2017, 09:02:07 AM
Hi

Thanks for your help Andrea/Reuben - I've got that working now.