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
> <[email protected]> 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"
> <[email protected] on behalf of [email protected]> 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
>> <[email protected]> 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"
>> <[email protected] on behalf of [email protected]> 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:[email protected]
>> **********************************************************************
>>
>> **********************************************************************
>> 4D Internet Users Group (4D iNUG)
>> Archive: http://lists.4d.com/archives.html
>> Options: https://lists.4d.com/mailman/options/4d_tech
>> Unsub: mailto:[email protected]
>> **********************************************************************
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive: http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub: mailto:[email protected]
> **********************************************************************
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive: http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub: mailto:[email protected]
> **********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************