Global notify if object has savedGlobal notify if object has saved
Old forum URL: forums.lhotka.net/forums/t/2595.aspx
pyhavaim posted on Tuesday, March 27, 2007
Hi!
This is probably offtopic but.
I'm using CAB on building the project, but now in the situation when in one form data will be saved. I want to notify another databound form, to reload the latest data.
For this reason I thought that static event will do the trick in BusinessBase object.
so. I have one static event, but there is no difference witch object is saved it will notify oll subscribers not the special Business object.
OrderBO.OnSave+=new EventHandler(OnReloadOrderData);
CustomerBO.OnSave+=new EventHandler(OnReloadCustomerData);
Does anyone have an idea how bound static event to only the specific class that inherits the BusinessBase object?
RockfordLhotka replied on Wednesday, March 28, 2007
CSLA version 2.1 has the ISavable interface, which should raises a Saved event for each object that is saved, giving your event handler access to both the original and new objects.
If you want, you could create a static observer that handles these events (in your objects' DP_XYZ and OnDeserialized events you'd hook the instance events to the static observer). This static observer could then raise a global event. Make sure your EventArgs subclass includes both the original and new object references.
CSLAer replied on Saturday, November 24, 2007
Appreciate if you can provide some simple code. Thanks
Copyright (c) Marimer LLC