Object out of sync in different windows

Object out of sync in different windows

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


jasonlaw posted on Wednesday, July 22, 2009

I have this problem all the time.
I have more than 1 windows on screen, and some of the windows actually containing same objects as other windows, but they load separately, meaning having different instance for the same object. Now if one if the object data has been updated in 1 window, other window with the same object will out of sync. Is there a good solution for this kind of problem?
Thanks in advance.

rfcdejong replied on Wednesday, July 22, 2009

If i understand you correctly u create a business object twice as two different instances, which is wrong if u want them to be the same. Create the business object just once and use that one in both windows.

If u can't do that or if u don't want to do that then i don't see another easy solution other then just reloading the business object with new data from the storage where the other business object persisted it.

RockfordLhotka replied on Wednesday, July 22, 2009

Ideally you'd have one object instance, and bind it to both windows.

Unfortunately, CSLA objects don't support multiple bindings from Windows Forms binding. So if you are in WPF this will work, but in Windows Forms it won't.

jasonlaw replied on Wednesday, July 22, 2009

But after saving we will get a new copy of BO, is there an elegant way refresh all binding in different window to the new BO instance?

RockfordLhotka replied on Wednesday, July 22, 2009

There's the Saved event, which a consumer can handle to know when the object
has been saved. The event provides a reference to the new object, so the
consumer can update their reference (and don't forget to unhook the event
from the old object and hook the event on the new object).

Rocky

rsbaker0 replied on Thursday, July 23, 2009

We have this issue as well -- the application has a non-modal tabbed interface and it's possible for the user to independently navigate to screens that show overlapping data.

We chose to handle it by having the tabs automatically refresh their contents from the database when they are visited (assuming the object is not dirty or broken, in which case we leave it alone). Sometimes this means refetching the root object, and sometimes refetching a lazy loaded child list.

We also aggressively save non-broken objects when the user's context changes, with the overall idea being "plan on it being saved unless you use undo".

So far, it demos very nicely, but of course this means the application is fairly "chatty" with respect to data portal traffic.

You can type a few characters one one tab, then visit another tab you've contrived to show the same data, and there is what you just typed. Make some changes there and go back to where you were, and you see the second set of changes, etc.

 

rfcdejong replied on Friday, July 24, 2009

It's a common issue, when to refresh data?
In almost every program u have some sort of refreshing the current view, a refresh button or explicitly refresh making it all croppy.

We've the same issue as well, but with CAG we have an EventAggregator to notify changes application wide.

Copyright (c) Marimer LLC