Which way is better to load BO?


Author
Message
Ben Hayat
Ben Hayat
Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
BO has an event called "ParentFormLoading" which allows me to connect to my customfill method. I can also call my customfill in the "FormLoad" of my form.



Naturally, I'd use the "FormLoad" event, but when I see BO has that event, I began to doubt whether the "FormLoad" is the way to do it. So, which way is the recommended way?



Thanks!

..ßen
Replies
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
Yes, Peter is correct.  The ParentFormLoading event is part of the IInitOnFormLoad interface implemented on the BusinessLayer class (it's also implemented on all of the list controls).  The ParentFormLoading is not meant to be handled within the BO class itself (unless you have come code that always needs to be executed when the form loads, in which case, yes, you should use it Wink), it's meant for the form to handle the method to allow you to place your population code in it. 

It's really 6 one way and 1/2 dozen the other... the ParentFormLoading on each BO is raised within the OnLoad of the form, right before the form's event is raised, so they are both equivalent.  The only difference is that the Form's Load is a "catch-all" and is a good place to put a PopulateAllBOs() method that can be called in a refresh.  The ParentFormLoading of the business object, since it's part of the IInitOnFormLoad interface gets raised according to the BO's InitializationPriority.  So, if you've got 3 BOs and 2 lists, and you need to call BO1.Fill(), List1.Requery(), BO2.Fill(), List2.Requery, BO3.Fill(), in that order, then you'll want to use the ParentFormLoading event and set the InitializationPriority on each of the objects in to control the order in which the event fires for each of the 5 objects.

Ben Hayat
Ben Hayat
Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
Thanks Ben; Great reply!

The ParentFormLoading is not meant to be handled within the BO class itself (unless you have come code that always needs to be executed when the form loads, in which case, yes, you should use it [Wink] ), it's meant for the form to handle the method to allow you to place your population code in it.
Makes sense!

So, if you've got 3 BOs and 2 lists, and you need to call BO1.Fill(), List1.Requery(), BO2.Fill(), List2.Requery, BO3.Fill(), in that order, then you'll want to use the ParentFormLoading event and set the InitializationPriority on each of the objects in to control the order in which the event fires for each of the 5 objects.
Good point!



Ben, I think this reply should make it to help file!

Thanks!

..ßen
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
I think this reply should make it to help file!

It should already be in the help file somewhere under InitializationPriority.  Maybe we just need to link to that from the ParentFormLoading event documentation...

Ben Hayat
Ben Hayat
Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
Ben Chase (06/04/2007)
I think this reply should make it to help file!




It should already be in the help file somewhere under InitializationPriority. Maybe we just need to link to that from the ParentFormLoading event documentation...




Ben, considering your full explanation (which is important for some up front decision making) and the sample Peter offered, provides an important value to this event. Even if some explanation was provided in InitializationPrioprity, I think second time explanation drives the point home!



Thanks for reply!

..ßen
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Ben Hayat - 18 Years Ago
Peter Jones - 18 Years Ago
Ben Hayat - 18 Years Ago
StrataFrame Team - 18 Years Ago
                     Thanks Ben; Great reply!
[quote]The ParentFormLoading is not...
Ben Hayat - 18 Years Ago
                         [quote]I think this reply should make it to help file![/quote] It...
StrataFrame Team - 18 Years Ago
                             [quote][b]Ben Chase (06/04/2007)[/b][hr][quote]I think this reply...
Ben Hayat - 18 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search