Rocky,
In version 3.5.1 you've added a ChildChanged event to the BusinessBase class. We use this event to get notified when a Child Object or a Child collection of a Root object changes. This works fine.
However, when we have the object graph Root -- Child collection -- Grandchild (collection), we don't receive a notification at the root level when a grandchild has changed. Such a notification can be used to enable/disable a Save button (or something like that). The reason that the event does not bubble up automatically is that BusinessListBase does not have the ChildChanged concept.
We've added a ChildChanged event to our BusinessListBase derived base class (see attachment). When adding a child item to the list, we hookup to the ChildChanged event of the child. If we receive a ChildChanged event from a child item, we raise the ChildChanged event of the List class. This works fine.
The problem with this approach is that we manually have to hookup to the ChildChanged event of the collection class. It would be nice to have Csla take care of this automatically.
I'd like to hear your opinion on this!
Cheers,
Herman
Thank you Herman,
There's another thread where this was discussed a couple weeks ago. I believe this has been addressed in yesterday's 3.6 pre-release so please look at that and see if it meets your needs.
The ChildChanged event starts at the parent level (above the originating object) and then bubbles from there all the way to the root object of the object graph.
RockfordLhotka:Thank you Herman,
There's another thread where this was discussed a couple weeks ago. I believe this has been addressed in yesterday's 3.6 pre-release so please look at that and see if it meets your needs.
The ChildChanged event starts at the parent level (above the originating object) and then bubbles from there all the way to the root object of the object graph.
Using version 3.6.1 this appears to have stopped bubbling up when an Object has been Deserialized using WCF.
It works fine when not using teh WCF. My other post here:
http://forums.lhotka.net/forums/thread/31083.aspx
In 3.6.0 there was a bug where the event was not bubbling
properly after deserialization. This was one of the things I specifically
worked on for 3.6.1.
In other words, there was a bug, and I thought I’d fixed
it (I have tests for several scenarios that do work).
So it sounds like I missed a scenario in my testing. You can
help me by providing either a very clear description of the failing scenario,
or a unit test that illustrates the failure.
Thank you,
Rocky
From: nj609eagle
[mailto:cslanet@lhotka.net]
Sent: Thursday, February 19, 2009 9:04 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Feature request: Bubble up ChildChanged event
in Parent/Child/Grandchild object graph
RockfordLhotka:
Thank you Herman,
There's another thread where this was discussed a couple weeks ago. I believe this has been addressed in yesterday's 3.6 pre-release so please look at that and see if it meets your needs.
The ChildChanged event starts at the parent level (above the originating object) and then bubbles from there all the way to the root object of the object graph.
Using version 3.6.1 this appears to have stopped bubbling up when an Object
has been Deserialized using WCF.
It works fine when not using teh WCF. My other post here:
http://forums.lhotka.net/forums/thread/31083.aspx
A Root object is of BusinessBase, call it Application.
Application has a Child property of BusinessBase, call it Section3_2.
Section3_2 has a child property of BusinessListBase, call it Salaries.
The Salary Item (BusinessBase) in the List has three numeric properties, Chargeable, non-Chargeable and total. A handler for Me.PropertyChanged which takes the Chargeable and non-chargeable and sets the total.
Section3_2 has a handler for Me.ChildChanged, and gets the total for all of the Salary Items listed and set the value to one of its own properties.
Application has a similar handler for Me.ChildChanged which sets properties for some of its values.
The Property Changed events will fire for the salary Item, but none of the Child Changed events will fire.
Being new to VS2008 and CSLA, I’m not really quite sure how to provide you with a unit test for the code that I’m running without the data source.
When you change the Total property, do you explicitly call
OnPropertyChanged(“Total”)?
Or are you storing Total in a managed backing field? In which
case are you calling SetProperty() to change it?
From: nj609eagle
[mailto:cslanet@lhotka.net]
Sent: Thursday, February 19, 2009 10:08 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] RE: Feature request: Bubble up ChildChanged
event in Parent/Child/Grandchild object graph
A Root object is of BusinessBase,
call it Application.
Application has a Child property of
BusinessBase, call it Section3_2.
Section3_2 has a child property of
BusinessListBase, call it Salaries.
The Salary Item (BusinessBase) in
the List has three numeric properties, Chargeable, non-Chargeable and total.
A handler for Me.PropertyChanged which takes the Chargeable and
non-chargeable and sets the total.
Section3_2 has a handler for
Me.ChildChanged, and gets the total for all of the Salary Items listed and set
the value to one of its own properties.
Application has a similar handler
for Me.ChildChanged which sets properties for some of its values.
The Property Changed events will
fire for the salary Item, but none of the Child Changed events will fire.
Being new to VS2008 and CSLA, I’m
not really quite sure how to provide you with a unit test for the code that
I’m running without the data source.
total is being stored in a managed backing field, and I'm calling Setproperty() to change it.
Attached is a crude diagram of the object model. it's similar to figure 5.1 on C# 2008 ( p188)
One other question – you are rehooking the childchanged
events in an ondeserialized() override correct?
Event hookups don’t survive serialization. CSLA rehooks
its internal event handlers, but if you are hooking events in your own code you
need to rehook them on deserialization.
Rocky
From: nj609eagle
[mailto:cslanet@lhotka.net]
Sent: Thursday, February 19, 2009 10:31 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] RE: RE: Feature request: Bubble up ChildChanged
event in Parent/Child/Grandchild object graph
total is being stored in a managed backing field, and I'm calling
Setproperty() to change it.
Attached is a crude diagram of the object model. it's similar to figure
5.1 on C# 2008 ( p188)
Ahh Haaa!!! No I'm not doing any type of rehooking of events.
Can you point me to a sample?
protected override void
OnDeserialized(System.Runtime.Serialization.StreamingContext context)
{
base.OnDeserialized(context);
this.ChildChanged += CustomerEdit_ChildChanged;
}
From: nj609eagle
[mailto:cslanet@lhotka.net]
Sent: Thursday, February 19, 2009 12:32 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] RE: RE: RE: Feature request: Bubble up
ChildChanged event in Parent/Child/Grandchild object graph
Ahh Haaa!!! No I'm not doing any type of rehooking of events.
Can you point me to a sample?
Thank you...I was just about to post that I found this elsewhere on the site.
Copyright (c) Marimer LLC