Re: xml data update and its derived data synchronization problem
Re: xml data update and its derived data synchronization problem
- Subject: Re: xml data update and its derived data synchronization problem
- From: Chuck Hill <email@hidden>
- Date: Thu, 18 May 2006 10:07:04 -0700
On May 18, 2006, at 8:32 AM, YL wrote:
I have an Entity with an attribute customData storing dynamic
information of
unpredictable structure in XML text format.
The instances of the Entity cache their customData in the converted
type of
NSDictonary for better performance.
If somehow the customData of an instance been changed by (another
session or
another app), through the typical data change notification, the
attribute
customData of all the living EO's that represent the same db record
will be
updated as expected, but their cached NSDictionary version of data
will not
be updated accordingly if no extra programming is done.
Any idea of how to solve the data synchronization problem?
You need to override the methods that EOF calls when the EO is
updated. Like this:
/**
* Overriden to clear cached values when object is saved in
another EC, the snapshot is updated.
*/
public void turnIntoFault(EOFaultHandler faultHandler)
{
super.turnIntoFault(faultHandler);
clearCachedValues();
}
/**
* Overriden to clear cached values when object reverted in ec.
*/
public void updateFromSnapshot(NSDictionary aSnapshot)
{
super.updateFromSnapshot(aSnapshot);
clearCachedValues();
}
/**
* Clears all cached values. This method should be overridden
in subclasses to clear the actual cached values.
*/
public void clearCachedValues()
{
}
Then put code in clearCachedValues() to recreate the dictionary. You
will also need to call clearCachedValues() manually in the methods
that manipulate customData so that the dictionary is that object is
also updated, though I expect you are already doing this.
I last tested that code a few months ago and I don't recall finding
any cases where it would not work. If you do find any cases, please
let me know.
Chuck
--
Coming in 2006 - an introduction to web applications using WebObjects
and Xcode http://www.global-village.net/wointro
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems. http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden