>Hello all,
>
>We are in a situation that a business object (we used the container class)that is not on a form needs to have a private datasession. Is there a way to make a business object with a private datasession?
Look at the Session class. You can just do this.addobject("oSession","mysession") and have mysession class defined as Session, with your properties (like DataSession=2 - private). However, I'm not sure that any code in your container will switch automatically to this.oSession.DataSessionID datasession - any method or event code executes in the datasession in which the object was created.
So you may just turn the things around and define your bizobjects as sessions - but this has two disadvantages. First, Session is not a container, it doesn't have object members. You can get around it by adding object properties, though, but then they don't have an automatic .parent backlink. Second, Session is a strictly non-visual class.
Another funny thing - I've created the following code:
Define Class mycnt As Container
Procedure Init
This.AddObject("oSS","mysess")
Endproc
Procedure hi
?"datasession", Set("Datasession")
Endproc
Enddefine
Define Class mysess As Session
DataSession= 2
Enddefine
When I instantiate myCnt, it doesn't create a new datasession (tried with "Add Object Oss as Mysess" as well). However, when I instantiate mysess first, it does create it - but stays at the current one. So I figure the way to go would be to
- create a session object
- set datasession to oSession.nDataSession
- instantiate your bizobject.