I have recently experienced the same issue. I see there were no answers forthcoming to this particular post. Maybe it has been answered in another thread but I have been unable to find it.
I am keen to be able to use nested objects for a number of reasons. So all i need to know is wherher the current ErrorProvider will work in this situation or do i need to flatten out my business object.
I'd appreciate any guidance
hi Andy
Thanks for the reply. I cannot find a way to override IDataErrorInfo. Complaint is that the Root BO does not implement IDataErrorInfo. Which i find puzzling as Core.BusinessBase declares and implements it. My knowledge of rules governing what can and cant be seen in descendant classes is lacking somewhat. Any ideas?
Pretty much as i thought it was done but obviously messed up somewhere the first time I tried. I now have it working but after putting a breakpoint in discover that it is only asked for errors relating to Root BO properties only. I Suspect that the problem lies with ErrorProvider and Binding Source.
Ill have to flatten out the business object.
Thanks
Hello,
I see from this post that you have found a solution to this issue which is, showing errors on Error Providers when they are bound to Nested Business Objects.
I havent been able to figure out how to expose the nested object's properties as the root BO's own.
In my case, I have a BusinessObject class which implements iDataErrorInfo and INotifyPropertChanged.All my objects derive from BusinessObject and these objects in turn, may contain each other. eg, Customer and Address both derive from BusinessObject.Customer has a property of type Address. How do I implement IDataErrorInfo and INotifyPropertChanged (these are implemented in BusinessObject) .
Appreciate any pointers,suggestions.
Thanks
Hi. I am not sure that I understand exactly what you are doing here. 'Customer and Address both derive from BusinessObject.Customer has a property of type Address' does not make sense to me if you are using CLSA in the convenrional manner, i.e. the use of the generic BusinessBase class.
However, to answer your question. I'll warn your that it is not pretty expecially if you hand craft your business objects.
The outer object (eg Customer) exposes the inner object's (eg Address) properties as its own and delegates calls to them. The outer object containsa static list of inner object property names The outer object explicitly implements IDataErrorInfo.this[string propName] and IDataErrorInfo.Error. The IDataErrorInfo property getter checks static list of Inner object property names and if present delegates to the inner object's IDataErrorInfo.this property. If the property does not belong to the inner object it handles the call by returning the its ValidationRules.GetBrokenRules().GetFirstBrokenRule(propName).Description.
I have to say the only reason I live with this solution is that I have my own application generator that knows about contained or inner objects and generates hte outer object delegating properties and the inner object property name list. In fact I go a bit further in that I can handle multiple inner objects, so the static list is actually a dictionary which maps the property to its correct inner object.
IDataErrorInfo.Error returns a concatenation of all BrokenRules in the outer inad inner objects very much as BusinessBase does
I hope that helps
Hello Simon_may,
Thanks for the detailed reply.
I did suspect that the only way for me to expose the nested object's properties as the Container/Outer,(not root) object's property is to explicitly define them.
"The outer object (eg Customer) exposes the inner object's (eg Address) properties as its own and delegates calls to them. The outer object containsa static list of inner object property names "
As I mentioned earlier, I have defined a BusinessObject class(not CSLA.BusinessBase) which implements
IDataEntity,
INotifyPropertyChanged,
IDataErrorInfo
All my business objects like Customer,Person,Name,Address etc derive from BusinessObject. And these may in turn contain each other. Like Customer has Person and Address.Person has Name and a date field.And so on..
All these are in turn contained in an object named "Universal". So,this has multiple,complex and more than 4 levels of nesting.One object might be part of multiple outer objects. (eg , Name will be contained by Customer,Contacts,Friends,etc).
I am binding "Universal" as binding source to the UI and to the ErrorProviders. So whenever there are errors on Name or Address, ErrorProvider does not show.
Now, BusinessObject implements IDataErrorInfo and iNotifyProperty changed.With our present architecture, I cannot implement these in the outer objects (eg customer).Like you, I do have a list which keeps tract of the errors associated with the Objects and they come up correctly when I iterate through the list. But this doesnt help the ErrorProvider.
I probably need to be able to get a reference to OuterObject from the current instance(of the child object) at runtime. I am going down the nesting, but need to go up and somehow assign the error to the parent object. This has to recursive as there are multiple nesting levels.
I hope there is a better and simple way of doing this.
I am going through JohnB's sample now and hope to see light.
Again,any pointers highly appreciated.
Thanks
Thanks JohnB.
This definitely gives me a lead to work on.
Copyright (c) Marimer LLC