Subform — how to get the CONTAINER OBJECT NAME in the subform form method? (17r5)

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Subform — how to get the CONTAINER OBJECT NAME in the subform form method? (17r5)

4D Tech mailing list
I am trying to create my own widgets. Widgets are subforms.

In the parent form, I want the  INSTANCE bound variable to be an object.
Inside the FORM METHOD of the widget (i.e. subform) I need to be able to find out the OBJECT NAME of the Parent INSTANCE of this widget.
But I cannot find any command that will actually retrieve this information from within the widget’s form method when the INSTANCE is of type Object.

In the subform’s method:
OBJECT Get pointer(Object with focus) = nil
OBJECT Get pointer(Object current) = nil
OBJECT Get name(subform) = “”
OBJECT Get pointer(Object subform container) = nil

————

*** So how does the subform’s form method find out the name of its INSTANCE in the parent form? ***

This is ridiculous if it cannot just because the bound variable is an object…

Please, someone, put me out of my misery by sharing the secret. I cannot see why the widget’s method cannot find out ‘who it belongs to’.

— Chris
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Subform — how to get the CONTAINER OBJECT NAME in the subform form method? (17r5)

4D Tech mailing list
Hi Chris,

Since your Subform Widget will be set to Object type, you can try this approach.

Create the object method for you subform widget with the following code:

If (Form event=On Load)
    OBJECT Get pointer(Object current)->:=New object("subformName";OBJECT Get name(Object current))
End if

Basically you are create a new property to your Form-data of the Subform Widget named "subformName". Once the form is loaded, you can find out the name of your subform container from the context of your subform execution simply by calling:

    Form.subformName

HTH,
Add




On 7/8/19, 10:46 AM, "4D_Tech on behalf of Chris Belanger via 4D_Tech" <[hidden email] on behalf of [hidden email]> wrote:

    I am trying to create my own widgets. Widgets are subforms.

    In the parent form, I want the  INSTANCE bound variable to be an object.
    Inside the FORM METHOD of the widget (i.e. subform) I need to be able to find out the OBJECT NAME of the Parent INSTANCE of this widget.
    But I cannot find any command that will actually retrieve this information from within the widget’s form method when the INSTANCE is of type Object.

    In the subform’s method:
    OBJECT Get pointer(Object with focus) = nil
    OBJECT Get pointer(Object current) = nil
    OBJECT Get name(subform) = “”
    OBJECT Get pointer(Object subform container) = nil

    ————

    *** So how does the subform’s form method find out the name of its INSTANCE in the parent form? ***

    This is ridiculous if it cannot just because the bound variable is an object…

    Please, someone, put me out of my misery by sharing the secret. I cannot see why the widget’s method cannot find out ‘who it belongs to’.

    — Chris
    **********************************************************************
    4D Internet Users Group (4D iNUG)
    Archive:  http://lists.4d.com/archives.html
    Options: https://lists.4d.com/mailman/options/4d_tech
    Unsub:  mailto:[hidden email]
    **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Subform — how to get the CONTAINER OBJECT NAME in the subform form method? (17r5)

4D Tech mailing list
After using OBJECT Get pointer(Object current)->:=New object("subformName";OBJECT Get name(Object current)), I got Form ={} or Form=null, depending on where the code was put (subform's form method or container's method).


If the subform container's code is:
-------
Case of
        : (Form event=On Load)
                $name:=OBJECT Get name(Object current)
                EXECUTE METHOD IN SUBFORM($name;"setFormName";*;$name)
End case
-------

and the setFormName method is:
-------
C_TEXT($1)
OB SET(Form;"subformName";$1)
-------

Objects in the widget can see the Parent form's name for their container in Form.subformName.
But it only works if the container's Variable Type is set to "None", and fails (Form=null) when the Type is set to "Object".

1) I was not expecting only "None" to work.
2) Is there a way for a widget's objects to know the container's name without help from the Host?  (Anything available from the inside?)

Thanks,
Keith - CDI

> On Jul 8, 2019, at 1:29 PM, Add Komoncharoensiri via 4D_Tech <[hidden email]> wrote:
>
> Hi Chris,
>
> Since your Subform Widget will be set to Object type, you can try this approach.
>
> Create the object method for you subform widget with the following code:
>
> If (Form event=On Load)
>    OBJECT Get pointer(Object current)->:=New object("subformName";OBJECT Get name(Object current))
> End if
>
> Basically you are create a new property to your Form-data of the Subform Widget named "subformName". Once the form is loaded, you can find out the name of your subform container from the context of your subform execution simply by calling:
>
>    Form.subformName
>
> HTH,
> Add
>
> 
>
>
> On 7/8/19, 10:46 AM, "4D_Tech on behalf of Chris Belanger via 4D_Tech" <[hidden email] on behalf of [hidden email]> wrote:
>
>    I am trying to create my own widgets. Widgets are subforms.
>
>    In the parent form, I want the  INSTANCE bound variable to be an object.
>    Inside the FORM METHOD of the widget (i.e. subform) I need to be able to find out the OBJECT NAME of the Parent INSTANCE of this widget.
>    But I cannot find any command that will actually retrieve this information from within the widget’s form method when the INSTANCE is of type Object.
>
>    In the subform’s method:
>    OBJECT Get pointer(Object with focus) = nil
>    OBJECT Get pointer(Object current) = nil
>    OBJECT Get name(subform) = “”
>    OBJECT Get pointer(Object subform container) = nil
>
>    ————
>
>    *** So how does the subform’s form method find out the name of its INSTANCE in the parent form? ***
>
>    This is ridiculous if it cannot just because the bound variable is an object…
>
>    Please, someone, put me out of my misery by sharing the secret. I cannot see why the widget’s method cannot find out ‘who it belongs to’.
>
>    — Chris
>    **********************************************************************
>    4D Internet Users Group (4D iNUG)
>    Archive:  http://lists.4d.com/archives.html
>    Options: https://lists.4d.com/mailman/options/4d_tech
>    Unsub:  mailto:[hidden email]
>    **********************************************************************
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Subform — how to get the CONTAINER OBJECT NAME in the subform form method? (17r5)

4D Tech mailing list
Perhaps I wasn't clear.

1. The subform container must have the Variable Type (in the property list) set to Object.
2. My suggested code must be placed in the Subform Container's Object Method.

Once the code (#2) is executed, you will be able to access the Form-Data property within the context of the Subform execution with Form.subformName.

If you are get Form = {} or Null, then you are most definitely not executing "Form.subformName" from the context of the Subform.

Regards,
Add





On 7/8/19, 1:54 PM, "4D_Tech on behalf of Keith Culotta via 4D_Tech" <[hidden email] on behalf of [hidden email]> wrote:

    After using OBJECT Get pointer(Object current)->:=New object("subformName";OBJECT Get name(Object current)), I got Form ={} or Form=null, depending on where the code was put (subform's form method or container's method).


    If the subform container's code is:
    -------
    Case of
    : (Form event=On Load)
    $name:=OBJECT Get name(Object current)
    EXECUTE METHOD IN SUBFORM($name;"setFormName";*;$name)
    End case
    -------

    and the setFormName method is:
    -------
    C_TEXT($1)
    OB SET(Form;"subformName";$1)
    -------

    Objects in the widget can see the Parent form's name for their container in Form.subformName.
    But it only works if the container's Variable Type is set to "None", and fails (Form=null) when the Type is set to "Object".

    1) I was not expecting only "None" to work.
    2) Is there a way for a widget's objects to know the container's name without help from the Host?  (Anything available from the inside?)

    Thanks,
    Keith - CDI

    > On Jul 8, 2019, at 1:29 PM, Add Komoncharoensiri via 4D_Tech <[hidden email]> wrote:
    >
    > Hi Chris,
    >
    > Since your Subform Widget will be set to Object type, you can try this approach.
    >
    > Create the object method for you subform widget with the following code:
    >
    > If (Form event=On Load)
    >    OBJECT Get pointer(Object current)->:=New object("subformName";OBJECT Get name(Object current))
    > End if
    >
    > Basically you are create a new property to your Form-data of the Subform Widget named "subformName". Once the form is loaded, you can find out the name of your subform container from the context of your subform execution simply by calling:
    >
    >    Form.subformName
    >
    > HTH,
    > Add
    >
    >
    >
    >
    > On 7/8/19, 10:46 AM, "4D_Tech on behalf of Chris Belanger via 4D_Tech" <[hidden email] on behalf of [hidden email]> wrote:
    >
    >    I am trying to create my own widgets. Widgets are subforms.
    >
    >    In the parent form, I want the  INSTANCE bound variable to be an object.
    >    Inside the FORM METHOD of the widget (i.e. subform) I need to be able to find out the OBJECT NAME of the Parent INSTANCE of this widget.
    >    But I cannot find any command that will actually retrieve this information from within the widget’s form method when the INSTANCE is of type Object.
    >
    >    In the subform’s method:
    >    OBJECT Get pointer(Object with focus) = nil
    >    OBJECT Get pointer(Object current) = nil
    >    OBJECT Get name(subform) = “”
    >    OBJECT Get pointer(Object subform container) = nil
    >
    >    ————
    >
    >    *** So how does the subform’s form method find out the name of its INSTANCE in the parent form? ***
    >
    >    This is ridiculous if it cannot just because the bound variable is an object…
    >
    >    Please, someone, put me out of my misery by sharing the secret. I cannot see why the widget’s method cannot find out ‘who it belongs to’.
    >
    >    — Chris
    >    **********************************************************************
    >    4D Internet Users Group (4D iNUG)
    >    Archive:  http://lists.4d.com/archives.html
    >    Options: https://lists.4d.com/mailman/options/4d_tech
    >    Unsub:  mailto:[hidden email]
    >    **********************************************************************
    >
    > **********************************************************************
    > 4D Internet Users Group (4D iNUG)
    > Archive:  http://lists.4d.com/archives.html
    > Options: https://lists.4d.com/mailman/options/4d_tech
    > Unsub:  mailto:[hidden email]
    > **********************************************************************

    **********************************************************************
    4D Internet Users Group (4D iNUG)
    Archive:  http://lists.4d.com/archives.html
    Options: https://lists.4d.com/mailman/options/4d_tech
    Unsub:  mailto:[hidden email]
    **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Subform — how to get the CONTAINER OBJECT NAME in the subform form method? (17r5)

4D Tech mailing list
Does this not create the .subformName attribute in the container object then?
And if you change records (i.e. entities) then you would lose that value instantly (in the subform FORM object).

I want some way of ’seeing’ the container’s object name from within the widget’s form method ALL THE TIME (i.e. every time it runs).
I don’t want to store the object name in the widget’s FORM object, since that means it gets inserted into the OBJECT variable (of the container).

I was hoping for:

I bind the object to the instance (CONTAINER) — this would be an entity, actually. So I don’t want to create attributes into the entity (via subform FORM manipulation).
• this means: every time the OBJECT (entity) is changed, then a ‘On Bound Variable Change’ event would be triggered in the widget.
    • if this means that the particular DATE attribute of that entity is changed, I update it in the widget. If not, ignore it.
(I made a method SET_FORM_OBJ_ATTR( dateAttributeName; ContainerName ). This is called in the CONTAINER ‘on load’ to configure.

SET_FORM_OBJ_ATTR ( ) maintains an object for that widget (instead of using Form., which would add whatever I put into that into the entity … ugh)
If (widgetStorage=Null)
        widgetStorage:=New object  // we use this to store our values instead of FORM because Form. will add attributes to our CONTAINER's object. We don't want that.
End if
If (widgetStorage[$2]#Null)
        widgetStorage[$2]:=New object("sourceAttr";$1)  // we add an 'attr' to widgetStorage named from CONTAINER and give it the 'sourceAttr' value
End if

This would create an object (hanging off of the widgetStorage { } object) wherein i could store my widget-specific (instance) data
I would access this data inside the widget with:
widgetStorage[ContainerName]  — this would give me the object wherein I am storage my widget-specific data.

This works great, other than …
I need to be able to know the CONTAINER OBJECT name from within the widget’s form method.

But there does not seem to be any way to find that out, as 4D just returns Nil on every command that **otherwise** would work!

Pretty pathetic, really.
What is the point of allowing an OBJECT type for the container, if you cannot even find out the name of the Container?
And the only way to ‘remember’ that name is to pass it to the widget, which would the add that name as an attribute to the Form object (of the container)?

Clearly, I cannot save that container name in the widget Form. object because:
1) this would create that attribute in the bound object;
2) this attribute would be lost every time the bound object is changed (which will be every time the record/entity is changed).

I would think that
OBJECT Get name(subform) should work correctly regardless of if the bound variable is an OBJECT;
OBJECT Get pointer(Object subform container) should return a pointer to the container object regardless of if the bound variable is an OBJECT.

But in both of these instances, it returns Nil.

**** So is there really no way for a widget/subform to find out its container’s name (or get a pointer to it) if an OBJECT is used for the bound variable? ****

— Chris


> On Jul 8, 2019, at 3:04 PM, Add Komoncharoensiri via 4D_Tech <[hidden email]> wrote:
>
> Perhaps I wasn't clear.
>
> 1. The subform container must have the Variable Type (in the property list) set to Object.
> 2. My suggested code must be placed in the Subform Container's Object Method.
>
> Once the code (#2) is executed, you will be able to access the Form-Data property within the context of the Subform execution with Form.subformName.
>
> If you are get Form = {} or Null, then you are most definitely not executing "Form.subformName" from the context of the Subform.
>
> Regards,
> Add
>
>
> 
>
>
> On 7/8/19, 1:54 PM, "4D_Tech on behalf of Keith Culotta via 4D_Tech" <[hidden email] on behalf of [hidden email]> wrote:
>
>    After using OBJECT Get pointer(Object current)->:=New object("subformName";OBJECT Get name(Object current)), I got Form ={} or Form=null, depending on where the code was put (subform's form method or container's method).
>
>
>    If the subform container's code is:
>    -------
>    Case of
>    : (Form event=On Load)
>    $name:=OBJECT Get name(Object current)
>    EXECUTE METHOD IN SUBFORM($name;"setFormName";*;$name)
>    End case
>    -------
>
>    and the setFormName method is:
>    -------
>    C_TEXT($1)
>    OB SET(Form;"subformName";$1)
>    -------
>
>    Objects in the widget can see the Parent form's name for their container in Form.subformName.
>    But it only works if the container's Variable Type is set to "None", and fails (Form=null) when the Type is set to "Object".
>
>    1) I was not expecting only "None" to work.
>    2) Is there a way for a widget's objects to know the container's name without help from the Host?  (Anything available from the inside?)
>
>    Thanks,
>    Keith - CDI
>
>> On Jul 8, 2019, at 1:29 PM, Add Komoncharoensiri via 4D_Tech <[hidden email]> wrote:
>>
>> Hi Chris,
>>
>> Since your Subform Widget will be set to Object type, you can try this approach.
>>
>> Create the object method for you subform widget with the following code:
>>
>> If (Form event=On Load)
>>   OBJECT Get pointer(Object current)->:=New object("subformName";OBJECT Get name(Object current))
>> End if
>>
>> Basically you are create a new property to your Form-data of the Subform Widget named "subformName". Once the form is loaded, you can find out the name of your subform container from the context of your subform execution simply by calling:
>>
>>   Form.subformName
>>
>> HTH,
>> Add
>>
>>
>>
>>
>> On 7/8/19, 10:46 AM, "4D_Tech on behalf of Chris Belanger via 4D_Tech" <[hidden email] on behalf of [hidden email]> wrote:
>>
>>   I am trying to create my own widgets. Widgets are subforms.
>>
>>   In the parent form, I want the  INSTANCE bound variable to be an object.
>>   Inside the FORM METHOD of the widget (i.e. subform) I need to be able to find out the OBJECT NAME of the Parent INSTANCE of this widget.
>>   But I cannot find any command that will actually retrieve this information from within the widget’s form method when the INSTANCE is of type Object.
>>
>>   In the subform’s method:
>>   OBJECT Get pointer(Object with focus) = nil
>>   OBJECT Get pointer(Object current) = nil
>>   OBJECT Get name(subform) = “”
>>   OBJECT Get pointer(Object subform container) = nil
>>
>>   ————
>>
>>   *** So how does the subform’s form method find out the name of its INSTANCE in the parent form? ***
>>
>>   This is ridiculous if it cannot just because the bound variable is an object…
>>
>>   Please, someone, put me out of my misery by sharing the secret. I cannot see why the widget’s method cannot find out ‘who it belongs to’.
>>
>>   — Chris
>>   **********************************************************************
>>   4D Internet Users Group (4D iNUG)
>>   Archive:  http://lists.4d.com/archives.html
>>   Options: https://lists.4d.com/mailman/options/4d_tech
>>   Unsub:  mailto:[hidden email]
>>   **********************************************************************
>>
>> **********************************************************************
>> 4D Internet Users Group (4D iNUG)
>> Archive:  http://lists.4d.com/archives.html
>> Options: https://lists.4d.com/mailman/options/4d_tech
>> Unsub:  mailto:[hidden email]
>> **********************************************************************
>
>    **********************************************************************
>    4D Internet Users Group (4D iNUG)
>    Archive:  http://lists.4d.com/archives.html
>    Options: https://lists.4d.com/mailman/options/4d_tech
>    Unsub:  mailto:[hidden email]
>    **********************************************************************
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Subform — how to get the CONTAINER OBJECT NAME in the subform form method? (17r5)

4D Tech mailing list
In reply to this post by 4D Tech mailing list
Does this not create the .subformName attribute in the container object then?
And if you change records (i.e. entities) then you would lose that value instantly (in the subform FORM object).

I want some way of ’seeing’ the container’s object name from within the widget’s form method ALL THE TIME (i.e. every time it runs).
I don’t want to store the object name in the widget’s FORM object, since that means it gets inserted into the OBJECT variable (of the container).

I was hoping for:

I bind the object to the instance (CONTAINER) — this would be an entity, actually. So I don’t want to create attributes into the entity (via subform FORM manipulation).
• this means: every time the OBJECT (entity) is changed, then a ‘On Bound Variable Change’ event would be triggered in the widget.
    • if this means that the particular DATE attribute of that entity is changed, I update it in the widget. If not, ignore it.
(I made a method SET_FORM_OBJ_ATTR( dateAttributeName; ContainerName ). This is called in the CONTAINER ‘on load’ to configure.

SET_FORM_OBJ_ATTR ( ) maintains an object for that widget (instead of using Form., which would add whatever I put into that into the entity … ugh)
If (widgetStorage=Null)
        widgetStorage:=New object  // we use this to store our values instead of FORM because Form. will add attributes to our CONTAINER's object. We don't want that.
End if
If (widgetStorage[$2]#Null)
        widgetStorage[$2]:=New object("sourceAttr";$1)  // we add an 'attr' to widgetStorage named from CONTAINER and give it the 'sourceAttr' value
End if

This would create an object (hanging off of the widgetStorage { } object) wherein i could store my widget-specific (instance) data
I would access this data inside the widget with:
widgetStorage[ContainerName]  — this would give me the object wherein I am storage my widget-specific data.

This works great, other than …
I need to be able to know the CONTAINER OBJECT name from within the widget’s form method.

But there does not seem to be any way to find that out, as 4D just returns Nil on every command that **otherwise** would work!

Pretty pathetic, really.
What is the point of allowing an OBJECT type for the container, if you cannot even find out the name of the Container?
And the only way to ‘remember’ that name is to pass it to the widget, which would the add that name as an attribute to the Form object (of the container)?

Clearly, I cannot save that container name in the widget Form. object because:
1) this would create that attribute in the bound object;
2) this attribute would be lost every time the bound object is changed (which will be every time the record/entity is changed).

I would think that
OBJECT Get name(subform) should work correctly regardless of if the bound variable is an OBJECT;
OBJECT Get pointer(Object subform container) should return a pointer to the container object regardless of if the bound variable is an OBJECT.

But in both of these instances, it returns Nil.

**** So is there really no way for a widget/subform to find out its container’s name (or get a pointer to it) if an OBJECT is used for the bound variable? ****

— Chris


> On Jul 8, 2019, at 3:04 PM, Add Komoncharoensiri via 4D_Tech <[hidden email]> wrote:
>
> Perhaps I wasn't clear.
>
> 1. The subform container must have the Variable Type (in the property list) set to Object.
> 2. My suggested code must be placed in the Subform Container's Object Method.
>
> Once the code (#2) is executed, you will be able to access the Form-Data property within the context of the Subform execution with Form.subformName.
>
> If you are get Form = {} or Null, then you are most definitely not executing "Form.subformName" from the context of the Subform.
>
> Regards,
> Add
>
>
> 
>
>
> On 7/8/19, 1:54 PM, "4D_Tech on behalf of Keith Culotta via 4D_Tech" <[hidden email] on behalf of [hidden email]> wrote:
>
>    After using OBJECT Get pointer(Object current)->:=New object("subformName";OBJECT Get name(Object current)), I got Form ={} or Form=null, depending on where the code was put (subform's form method or container's method).
>
>
>    If the subform container's code is:
>    -------
>    Case of
>    : (Form event=On Load)
>    $name:=OBJECT Get name(Object current)
>    EXECUTE METHOD IN SUBFORM($name;"setFormName";*;$name)
>    End case
>    -------
>
>    and the setFormName method is:
>    -------
>    C_TEXT($1)
>    OB SET(Form;"subformName";$1)
>    -------
>
>    Objects in the widget can see the Parent form's name for their container in Form.subformName.
>    But it only works if the container's Variable Type is set to "None", and fails (Form=null) when the Type is set to "Object".
>
>    1) I was not expecting only "None" to work.
>    2) Is there a way for a widget's objects to know the container's name without help from the Host?  (Anything available from the inside?)
>
>    Thanks,
>    Keith - CDI
>
>> On Jul 8, 2019, at 1:29 PM, Add Komoncharoensiri via 4D_Tech <[hidden email]> wrote:
>>
>> Hi Chris,
>>
>> Since your Subform Widget will be set to Object type, you can try this approach.
>>
>> Create the object method for you subform widget with the following code:
>>
>> If (Form event=On Load)
>>   OBJECT Get pointer(Object current)->:=New object("subformName";OBJECT Get name(Object current))
>> End if
>>
>> Basically you are create a new property to your Form-data of the Subform Widget named "subformName". Once the form is loaded, you can find out the name of your subform container from the context of your subform execution simply by calling:
>>
>>   Form.subformName
>>
>> HTH,
>> Add
>>
>>
>>
>>
>> On 7/8/19, 10:46 AM, "4D_Tech on behalf of Chris Belanger via 4D_Tech" <[hidden email] on behalf of [hidden email]> wrote:
>>
>>   I am trying to create my own widgets. Widgets are subforms.
>>
>>   In the parent form, I want the  INSTANCE bound variable to be an object.
>>   Inside the FORM METHOD of the widget (i.e. subform) I need to be able to find out the OBJECT NAME of the Parent INSTANCE of this widget.
>>   But I cannot find any command that will actually retrieve this information from within the widget’s form method when the INSTANCE is of type Object.
>>
>>   In the subform’s method:
>>   OBJECT Get pointer(Object with focus) = nil
>>   OBJECT Get pointer(Object current) = nil
>>   OBJECT Get name(subform) = “”
>>   OBJECT Get pointer(Object subform container) = nil
>>
>>   ————
>>
>>   *** So how does the subform’s form method find out the name of its INSTANCE in the parent form? ***
>>
>>   This is ridiculous if it cannot just because the bound variable is an object…
>>
>>   Please, someone, put me out of my misery by sharing the secret. I cannot see why the widget’s method cannot find out ‘who it belongs to’.
>>
>>   — Chris
>>   **********************************************************************
>>   4D Internet Users Group (4D iNUG)
>>   Archive:  http://lists.4d.com/archives.html
>>   Options: https://lists.4d.com/mailman/options/4d_tech
>>   Unsub:  mailto:[hidden email]
>>   **********************************************************************
>>
>> **********************************************************************
>> 4D Internet Users Group (4D iNUG)
>> Archive:  http://lists.4d.com/archives.html
>> Options: https://lists.4d.com/mailman/options/4d_tech
>> Unsub:  mailto:[hidden email]
>> **********************************************************************
>
>    **********************************************************************
>    4D Internet Users Group (4D iNUG)
>    Archive:  http://lists.4d.com/archives.html
>    Options: https://lists.4d.com/mailman/options/4d_tech
>    Unsub:  mailto:[hidden email]
>    **********************************************************************
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Subform — how to get the CONTAINER OBJECT NAME in the subform form method? (17r5)

4D Tech mailing list
In reply to this post by 4D Tech mailing list
SOLUTION:

On the parent form:
The CONTAINER’s bound variable is an OBJECT  (in particular, the entity I am editing).
The CONTAINER SCRIPT is:

  // script of the included formDate CONTAINER
Case of
        : (Form event=On Load)
                EXECUTE METHOD IN SUBFORM(OBJECT Get name;"SET_FORM_OBJ_ATTR";*;"formDate")  // formDate is the attribute we want handled by the widget
End case
“formDate” in this instance is the ATTRIBUTE we want the widget to operate on.

— THIS will be the entire configuration process for the widget! (as far as the parent is concerned).

IN THE WIDGET COMPONENT:

  // SET_FORM_OBJ_ATTR ( AttributeName ) -- this is the name of the ATTRIBUTE we are GET / SETTING.
  // for example, it may be   "formDate"    and it will be used as  “Form[Attribute]. to SET or GET the value from the CONTAINER's OBJECT
This value is stored in the widget’s special ‘ formData’ object as an attribute named “sourceAttr"
C_TEXT($1)  // the attribute name where the value is stored
$formObjPtr:=OBJECT Get pointer(Object named;"formData")  // this is the object on the form where we are storing the 'form data'
If ($formObjPtr->=Null)  // no object? then we need to create it. This will always be the case when this is called
        $formObjPtr->:=New object
end if
$obj_FormData:=OBJECT Get pointer(Object named;"formData")->  // this is the form data object
$obj_FormData.sourceAttr:=$1



IN THE WIDGET:
I created an OBJECT VARIABLE in the widget form. It’s object name is   “formData"
I use this OBJECT VARIABLE like I would have the Form. object. That way, the attributes I set do not become part of the CONTAINER OBJECT.
• the GET / SET attribute name is     .sourceAttr.
To manipulate this object:
$obj_FormData:=OBJECT Get pointer(Object named;"formData")->  // this is the form data object

Then the attributes can be manipulated with   $obj_FormData. attribute
So to get / set the SOURCE ATTRIBUTE that we are editing:
$obj_FormData.sourceAttr    // this will be the DATE we are editing.

Any other data I need to store for this operation (such as  
•  .theDate — retrieved from the sourceAttr   ($obj_FormData.sourceAttr)
• .theDay
• .theMonth
• .theYear

etc. all the data I need to store to handle the widget.

NOW:

• whenever the source object is changed (entity!) — the ‘On Bound Variable Change’ is triggered in the Widget.
I can get the DATE I need to edit using the
.obj_FormData.sourceAttr method explained above. Then I can update the stuff I need   (.theDay, .theMonth, .theYear etc).

ON DEACTIVATE — I can update the CONTAINER’s date attribute as needed:
Form[$obj_FormData.sourceAttr]:=$obj_FormData.theDate  // copy the result to the bound Object's DATE Attribute we were editing


———

without doing too much more explaining, those are the things I discovered will work.

In short:
I put an OBJECT VARIABLE onto the widget’s form.
I use this object variable to store the information I need to manage.
I tell the widget the name of the attribute that it is working on inside the CONTAINER OBJECT. This is stored as an attribute in that special var
I can GET / SET the value in that attribute as per above   (It is   Form [ name of attribute ] ) !

hope that helps.
I look forward to getting my widgets made and perhaps others may be interested in using them.

I thank the developers that chimed in on this matter for me. I appreciate it.

— Chris


> On Jul 8, 2019, at 11:46 AM, Chris Belanger <[hidden email]> wrote:
>
> I am trying to create my own widgets. Widgets are subforms.
>
> In the parent form, I want the  INSTANCE bound variable to be an object.
> Inside the FORM METHOD of the widget (i.e. subform) I need to be able to find out the OBJECT NAME of the Parent INSTANCE of this widget.
> But I cannot find any command that will actually retrieve this information from within the widget’s form method when the INSTANCE is of type Object.
>
> In the subform’s method:
> OBJECT Get pointer(Object with focus) = nil
> OBJECT Get pointer(Object current) = nil
> OBJECT Get name(subform) = “”
> OBJECT Get pointer(Object subform container) = nil
>
> ————
>
> *** So how does the subform’s form method find out the name of its INSTANCE in the parent form? ***
>
> This is ridiculous if it cannot just because the bound variable is an object…
>
> Please, someone, put me out of my misery by sharing the secret. I cannot see why the widget’s method cannot find out ‘who it belongs to’.
>
> — Chris

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************