No notification from nested child BOs/BCs with Active Objects 1.6 and CSLA 1.5

No notification from nested child BOs/BCs with Active Objects 1.6 and CSLA 1.5

Old forum URL: forums.lhotka.net/forums/t/2228.aspx


tgasch posted on Monday, January 29, 2007

This is not a direct CSLA problem, but I'm using Petar's Active Objects with CSLA. In the old forum, there were a lot of dicussions about Active Objects, so I thought to post it here would help me.
I'm using the AO-Code 1.6 with CSLA 1.5 and it works great for the first steps (thanks to Petar!). Now I'm digging into a more complex scenario, where I have some problems. Having a BC and getting notified by it's childs is no big deal (thanks to AO), but if the childs have nested BOs or BCs the notification won't run through to the top level BC (obviously I did something wrong).

I have a BC called cVehicles (with an attribut RegisterNotify("IsValid, IsDirty")) containing BO items (cVehicle-Objects). So far so good. My cVehicle has nested BOs and BCs. First of all, I added attributs to all members of cVehicle, which I want to observe. For example for my nested BC in cVehicle:

<RegisterNotify("IsValid, IsDirty")> _
Private moConstraintAssignments As cConstraintAssignments = cConstraintAssignments.NewConstraintAssignments()

Like the "toplevel" BC, the nested BC "cConstraintAssignments" has the attribute:

<Serializable(), RegisterNotify("IsValid, IsDirty")> _
Public Class cConstraintAssignments
   Inherits ActiveBusinessCollectionBase

So if I'm going to change a child items property (called cConstraintAssignment) of this nested BC, I receive this notification only within the BC cConstraintAssignments (the "Protected Overrides Sub OnNotification()" method is called..).
BUT the events are not fired to the higher level BC!!??
What can be the reason for that ?? Even if I manually call "Notify(e.Name, e.Value)" in the "OnNotification()"-method, nothing happens. Another problem is, if I add or delete items to/from the BC, I'm generally not notified.. :-(
I've looked at Petar's sample application "ActiveTracker", where a similar scenario is implemented . There's (for example) the BO Project which observes its nested BC ProjectResources. The idea is, that if we change a role in any assigned ProjectResource, we want to get notified, isn't it ? (We also receive the "IsDirty" event then..). So my implementation looks similar (I think) to the sample application. But it turns out, that there might be a problem in the sample application or even in the AO-Framework. If I run the sample application and edit a project, any change of roles is NOT notified!!!! But after doing some changes and SAVING the object, THEN I receive changes of the role property!!!! Can anybody confirm that behaviour??!! Perhaps this is the problem, why it doesn't work in my scenario, too.
Thank you for an answer, I'm looking forward to get any information that will help me out solving this "nesting" (or nasty :-( ) observing problem.

regards,
Thomas

tgasch replied on Monday, February 05, 2007

I found the mistake !!

For some reasons (debugging, testing) I commented some ESSENTIAL lines out (in my BO of my Root-BC). You HAVE to call RegisterAndSubscribe() within the constructor(s), at the end of the  Fetch-methods and at the end of any Create-method. After enabling these lines of code again, it worked!!!

Have fun with CSLA.NET and AO !!!

Thomas

Copyright (c) Marimer LLC