StrataFrame Forum

Does BBS clone Business Object?

http://forum.strataframe.net/Topic29585.aspx

By dgsoft - 2/18/2011

Hi,

I wrote business logic inside BO.

For example, 

BO1.pmks_relatedBO = BO2

So, for BO1 I made public property AS BO2




In Design Time - in Property Grid - for BO1  I select BO2.

Then I bild BO1 to Textboxes and Also make BO1BBS and Bind it to the Grid.

Some properties setter has custom code inside which ask some properties of BO2

When I change textbox value - I have no problem - all works as expected

When I change cell value in the Gird - I'v got an error 

When I debug code - I can see my BO2 is Nothing! But in design time and runtime when I change textbox values - BO2 exist.

Then appears a question. Where is instance of BO2? Is BBS clone businessobject and work with copy of instance or?




Thanks for the help

Denis.
By dgsoft - 2/18/2011

I debug code and found next thing...

1) When property change fired in BO which bind to the Grid using BBS - ParentBusinessObject - correct! and there 1 record inside!

So far, exist possibility to make a reference  to instance of BO from another BO which located on the form!

But how?





By dgsoft - 2/18/2011

Ok. I found in source


BusinessBindingSource.vb


Private Function CreateShareAndAddBusinessObject(ByVal index As Integer) As BusinessLayer
'-- Create a new object
Dim loReturn As BusinessLayer = CType(Activator.CreateInstance(Me._BusinessObject.GetType()), BusinessLayer)

'-- Share the table
Me._BusinessObject.ShareCurrentDataTable(loReturn)

'-- Set the parent business object of the instance object
loReturn.ParentBusinessObject = _BusinessObject.ParentBusinessObject

'-- Add the object to the list
Me._BusinessObjectList.Add(index, loReturn)

'-- Return the new object
Return loReturn
End Function





HERE.. I WANNA have a HOOK like RaiseEvent CustomizeMyBusinessObject(loReturn)

and there.. in BBS.CustomizeMyBUsinessObject I can make

Public Sub CustomizeMyBusinessObject(ByVal toReturn as BusinessLayer) Handles BBS.CustomizeMyBusinessObject

Dim loBO as MyBO = TryCast(toReturn, MyBO)
loBO.myParentBO = BO2
loBO.myAnotherBO = BO3





That could be a solution for me and Now last question Smile

It is possible to make without modification in StrataFrame source code? Somewhere in subclasses...