Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: createchild  (Read 16777 times)
Miguel G.
Posts: 6


« on: July 26, 2010, 11:38:53 am »

    DEFINE w ui.Window,
           f ui.Form,
           nw, nf, o om.DomNode
           
    LET w = ui.Window.getCurrent()
    LET nw = w.getNode()
    CALL nw.setAttribute("text", "Form1")
   
    LET f = w.createForm("F1")
    LET nf = f.getNode()

    LET o = f.createChild("label") --> Here I get this error :

                                                           FORMS statement error number -8003.
                                                           Dom: A node is inserted somewhere it doesn't belong.

How to resolve this ?
Thanks in advance.
Sebastien F.
Four Js
Posts: 509


« Reply #1 on: July 26, 2010, 02:23:25 pm »

Miguel,

You cannot directly create a Label node under a Form node, for ex, see a .42f file produced from a .per with fglform.

For a complete definition of the AUI tree, see FGLDIR/doc/dtd/UserInterface.dtd

Note however that we may change that definition in future version, try to centralize as much as possible the creation of dynamic form elements.

Note also that you mist use "Label" with a capital letter.

Seb
.
Four Js
Posts: 115


« Reply #2 on: July 26, 2010, 03:10:36 pm »

I would also recommend to be very careful when building dynamically your form.

Some attributes are mandatory and the checking is done directly by fglform - your aui tree may be correct from a DTD perspective, but not from the application point of view ; so you may encounter very strange results as the front ends expect some attributes to be defined the way fglform does.

GDC also expects to have some attributes at creation time, so if you make something like


Code
  1. myLabel.setAttribute("posX","2")
  2. CALL ui.interface.refresh()
  3. myLabel.setAttribute("posY","5")
  4.  

posY = 5 will be ignored, as the widget will be created once ui.interface.refresh() is called, at this time posY equals 0, and GDC does not manage further changes of posY attribute.

So please make sure your form is created the same way fglform would create it.
Sebastien F.
Four Js
Posts: 509


« Reply #3 on: July 26, 2010, 03:42:20 pm »

I second Pierre-Nicolas.

Note that fglform can execute with a runtime license, so normally you could generate a .per form dynamically, compile it from the program with
 RUN "fglform ..."
 and then load it with om.DomNode.loadXml() ...

I did not test but you could give it a try... I would use files in /tmp of course with process id to avoid conflicts with other users.

Seb
Miguel G.
Posts: 6


« Reply #4 on: July 26, 2010, 07:16:03 pm »

Thank you very much, to all.
Miguel G.
Posts: 6


« Reply #5 on: July 30, 2010, 05:38:15 pm »

DEFINE w ui.Window,
           f ui.Form,
           nw, nf, ng, o om.DomNode
           
    LET w = ui.Window.getCurrent()
    LET nw = w.getNode()
    CALL nw.setAttribute("text", "Form1")
   
    LET f = w.createForm("F1")
    LET nf = f.getNode()

    LET ng = f.createChild("Grid")

    LET o = ng.createChild("Label")

This works :)
-------------------------------------------------
But if I try


LET ng = f.createChild("Tree") or
LET ng = f.createChild("Table")  or
LET o = ng.createChild("Edit")    --> Here I get this error :

                                                           FORMS statement error number -8003.
                                                           Dom: A node is inserted somewhere it doesn't belong.

How to resolve this ?
Thanks in advance.
Leo S.
Four Js
Posts: 126


« Reply #6 on: July 30, 2010, 05:53:15 pm »

Miguel, you should run the table demos and look in the GDC in debug mode (gdc -aD) via Control-Right click in the AUI tree inspector how the real table structure looks like. You can also create a simple form containing a table and look in the resulting .42f file how the structure looks like.
Any attempt to create an invalid structure is fortunately blocked by the run time system, however even if the structure is ok, there may be semantic errors as Pierre Nicolas and Seb pointed out. You should already program a while in Genero before you start to make AUI tree manipulations. If you are an expert however, creating forms on the fly can be an option to save the creation of a lot of boilerplate forms.
Kind Regards, Leo
Sebastien F.
Four Js
Posts: 509


« Reply #7 on: July 30, 2010, 06:36:36 pm »

Miguel,

May I ask why you need to generate forms dynamically?
Remember the AUI tree is subject of changes between major product versions.
Note also that fglform has special rules when generating the .42f from the .per.

Leo:
Don't you think it's more safe to generate a .per file on the fly, then compile with RUN "fglform ..." and then load the 42f with OPEN FORM / DISPLAY FORM or OPEN WINDOW .. WITH FORM? Am I missing something? Why would this not work?

Seb
Leo S.
Four Js
Posts: 126


« Reply #8 on: July 30, 2010, 07:07:22 pm »

Seb,yes: creating complete new forms on the fly should go thru fglform. I should have made that more clear.
Miguel G.
Posts: 6


« Reply #9 on: August 02, 2010, 09:18:08 am »

Thank you, to all.
Reuben B.
Four Js
Posts: 1049


« Reply #10 on: August 03, 2010, 12:50:02 am »

...
Note that fglform can execute with a runtime license...

can we get that added to the documentation somewhere.  I wasn't aware of it.

...
creating forms on the fly can be an option to save the creation of a lot of boilerplate forms.
...

... in order to utilise creating forms on the fly, we ought to be able to create dialogs on the fly as well.  I have a generic zoom window routine that could potentially create forms on the fly but without generic dialogs I have a DISPLAY ARRAY of an arbitrarily large number of columns, and then hide the columns I don't want to see.   I'd love to have a generic table maintenance routine but at the moment the only way to do that is with an INPUT/INPUT ARAY/CONSTRUCT using an arbitrary large number of fields.

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Sebastien F.
Four Js
Posts: 509


« Reply #11 on: August 03, 2010, 09:35:59 am »

...
Note that fglform can execute with a runtime license...

can we get that added to the documentation somewhere.  I wasn't aware of it.


Warning added to doc:

https://4js.com/techdocs/genero/fgl/devel/DocRoot/User/Tools.html#TL_FGLFORM

https://4js.com/techdocs/genero/fgl/devel/DocRoot/User/Installation.html#INST_LICENSING
Miguel G.
Posts: 6


« Reply #12 on: August 13, 2010, 09:47:47 am »

Good morning,

I've got a menu with some action, then I create another MenuAction at run time. The button is shown on the menu, but when I click on it, nothing happens why ? How can I catch the event or fire the event of that menu button ?

LET nMa = nMenu.createChild("MenuAction")
CALL nMa.setAttribut("name", "dosomething")
.
Four Js
Posts: 115


« Reply #13 on: August 13, 2010, 11:08:59 pm »

Runtime team will confirm, but you're taking the concept in the wrong way here. Let me explain:

the AUI tree is the result of a combination between:
1. the forms read from .per files (mostly: the FORM node)
2. business logic from your 4gl code (moslty: DIALOG / MENU nodes)

So the sum of these two items produces the AUI tree which is sent to the front ends which render GUI.

If you create manually MenuActions, you just add an entry in the AUI Tree ; but there is no business logic behind, the 4GL runtime has no idea on what it has to do when the button is clicked.

To get an imaged view, let say you gave the construction plan (.4gl) to your electrician. He will then add some switches on the wall and add wires from the switch to the main switchboard.
By adding manually menuactions, you're just addin switches on the wall ; but you're not adding the wires - and you can't, only the electrician can.

This is one of the lacks of 4GL today: you can't build a generic interface from scratch, there are still some pieces that need to be hardcoded in your 4GL file.

As a workaround you can do something like

Code
  1. MENU
  2.  COMMAND "a"
  3.  COMMAND "b"
  4.  COMMAND "c"
  5.  COMMAND "d"
  6.   ...
  7.  BEFORE MENU
  8.    IF do_some_tests() THEN
  9.      CALL set_actions_xxx_enabled(TRUE)
  10.   ELSE
  11.      CALL set_actions_xxx_enabled(FALSE)
  12.  END IF
  13. ...
  14.  

where the function enables or disables the corresponding actions...

with a sufficient number of COMMANDs.
Miguel G.
Posts: 6


« Reply #14 on: August 16, 2010, 12:36:49 pm »

Tank you Mr Pierre Nicolas Rigal
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines