Complex BO question


Author
Message
Michael Cobb
Michael Cobb
StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)
Group: Forum Members
Posts: 26, Visits: 1K
I have a complex BO that contains a number of additional BOs.  For simplicity, my complex BO is called MainBO which instantiates _BO1, _BO2 and _BO3 (these are private BOs contained within MainBO).  _BO1 has columns called test1, test2, and test3.  _BO2 has columns called test4, test5 and test6.  _BO3 has columns called test7 and test8.  I have exposed these columns through Custom Field Properties and each is bound to a form.  Each is populated through a scalar query executed during the Custom Field's Property Get procedure.  The form only has MainBO dropped on it.  When running the form, as I navigate through records everything works perfectly.  When I click the edit toolstrip button, all of these fields become editable.  If I edit fields that were originally part of MainBO, the values save properly.  If I edit the fields exposed through MainBO such as test1, the Property Set procedures work perfectly.  The problem is that clicking the save button causes Property Gets to fire, so the new values for test1 - test8 get reset to their original values before they can be saved.  I am trying to save these secondary BOs in the BeforeSave event for MainBO, but by the time that code executes, the values for test1 - test8 have already been reset.

Is putting the code to retrieve the appropriate values for the secondary BOs in Property Get procedures a bad idea?  If so, where should that code be placed?  Better yet, is this the approach I should be using?

I'm not sure if it makes a difference but I'm using the StrataFrame Maintenance form so the initial save to MainBO is called through the MaintenanceFormToolStrip.

To complicate this further, what if the records I want to retrieve from _BO2 and _BO3 are dependent on values from _BO1?  Basically, MainBO and _BO1 can be thought of as a logical "record" although the values are spread across two tables (and I cannot redesign the db).  The only keys defined in the database are primary keys for each table represented by the BOs.  There are no foreign keys defined in the database-- all of the fk relationships are managed by existing software code.  I need to be able to save values first to _BO1 and then to MainBO, and each of these may contain lookup values that correspond to columns in _BO2 and _BO3.

This is my first complex BO in the real world, so once I am able to get past this hurdle I will test the Add/Delete functionality and if everything works I'll be able to use this as a model for other complex BOs.

Thanks,

Michael Cobb

Reply
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
It's fine that you leave the population of _BO1 and _BO2 in the MainBO.Navigated and _BO1.Navigated events respectively.  All you need to do is test on the BO.IsEmpty property (which if you don't have, since it was added in 1.6.1, you can test .Count = 0) to make sure that there are records in the BO before you try to work with it.  Also, I would recommend populating the MainBO within the ParentFormLoading event.  The ParentFormLoading event fires before any of the controls are bound, so, if you fill MainBO within it, the Navigated event will fire when the MainBO is filled, and the other 2 business objects will then be filled within that event.  It would also be recommended to test the .IsDirty property in your custom business objects, because while you should normally have some records, you might run into a case where you legitimatly don't have any records, so you would need to prepare and test for that condition.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Michael Cobb - 18 Years Ago
StrataFrame Team - 18 Years Ago
Michael Cobb - 18 Years Ago
Michael Cobb - 18 Years Ago
StrataFrame Team - 18 Years Ago
Michael Cobb - 18 Years Ago
StrataFrame Team - 18 Years Ago
Michael Cobb - 18 Years Ago
StrataFrame Team - 18 Years Ago
Michael Cobb - 18 Years Ago
Trent L. Taylor - 18 Years Ago
Michael Cobb - 18 Years Ago
Trent L. Taylor - 18 Years Ago
Michael Cobb - 18 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search