Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Custom.dataenvironment.crash
Message
From
17/06/1999 19:59:13
 
 
To
17/06/1999 18:39:19
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00230749
Message ID:
00231152
Views:
19
Let me explain what I do with this:

I have a container (cntBiz) which has a property (oSession) which holds a reference to a subclassed Session object which is defined in a .prg. As I said before, oSession has the oDataEnvironment property which holds a reference to the DataEnvironment object also defined in the same .prg.

I use cntBiz for method/event hooks called from the .prg class definitions as well as custom properties which set DataEnvironment properties. I use the same type of scheme for lblCursor and lblRelation objects which can be added to cntBiz at design time and run time (but never finishes Init at runtime to keep it lite). All of this allows me to to design a Biz object with the class designer without using a form or always subclassing the .prg data classes. It is also more componentized than using a form.

CntBiz also has all the cursor update, revert, changed, transaction, etc. methods. The only drawback (if you want to call it that) is that the DataSession loses scope outside of oDataSession, so SET DATASESSION is needed in some of the methods.

I can create as many cntBiz instances as I want or have a collection of them.

All my forms have to know is what cntBiz object to use and a simple oForm.DataSessionID = oBiz.oSession.DataSessionID does the trick.

Furthermore, I am finding that this model will be good for other middle-tier stuff I'm planning.




>Your example was not an example of containership. Just because your Custom class holds a reference to a session object and that session object holds a reference to a dataenvironment object, doesn't make the session a member of the custom and the DE a member of the session. Yes, a dataenvironment object can exist independently, but if you want to contain it, you have to contain it in a form.

>What's more giving a custom object a reference to a session object, does not automatically give that custom object a private datasession. (BTW, a base class session object gets you nowhere toward a private datasession anyway: the datasession propetry is read-only at run time; you have to subclass it to change the datasession property to 2- private). Yes, you can add a reference to the object, check it's datasession property and SET DATASESSION to that value. That will work.
>
>From a strategy point of view however, why use DE objects and custom objects at all? Why not just base you business classes on the session class and be done with it?
>
>
>
>
>>Terry,
>>
>>It's not a form container.
>>
>>Try something this with the custom class Init:
>>
>>WITH This
>>
>> .AddPropery([oSession], .NULL.)
>> .oSession = CREATEOBJECT([Session])
>> .oSession.AddProperty([oDataEnvironment], .NULL.)
>> .oSession.oDataEnvironment = CREATEOBJECT([DataEnvironment])
>>
>> *!* Now you can add your cursors
>>
>> WITH .oSession.oDataEnvironment
>>
>> .AddObject([Cursor1], [Cursor])
>> *!* blah, blah, blah
>>
>> ENDWITH
>>
>>ENDWITH
>>
>>
>>>In the init event of a subclass of the custom object from _base.vcx, I have the following code:
>>>
>>>this.addobject("de","dataenvironment")
>>>this.de.addobject("cursor1","cursor")
>>>this.de.cursor1.alias="custs"
>>>this.de.cursor1.cursorsource="customers"
>>>this.de.cursor1.database="cc"
>>>this.de.cursor1.nodataonload=.f.
>>>
>>>I get the error:
>>>"Object class is invalid for this container" upon attempting to instantiate the dataenvironment object.
>>>
>>>I have tried using the container class instead of the custom class with the same results.
>>>
>>>I heard this can be done. Does anyone know what I am doing wrong here?
>>>TIA
- Jeff
Previous
Reply
Map
View

Click here to load this message in the networking platform