Four Js Development Tools Forum

Discussions by product => Genero BDL => Topic started by: Gary C. on May 01, 2017, 12:51:10 pm



Title: Construct Question
Post by: Gary C. 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: Daniel N. 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: Daniel N. 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 B. 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
  1.        CONSTRUCT BY NAME where_clause ON field1, field2, field3
  2.        BEFORE CONSTRUCT
  3.            DISPLAY ">0" TO field1
  4.            CALL DIALOG.setFieldValue("field2", "A*")
  5.  
  6.        AFTER CONSTRUCT
  7.            IF int_flag THEN
  8.                EXIT CONSTRUCT
  9.            END IF
  10.            DISPLAY "Field 1 = ", GET_FLDBUF(field1)
  11.            DISPLAY "Field 2 = ", DIALOG.getFieldValue("field2")
  12.    END CONSTRUCT
  13.    DISPLAY where_clause


Title: Re: Construct Question
Post by: Gary C. on May 03, 2017, 09:02:07 am
Hi

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