Re: refreshRefetchedObjects

Chuck Hill <[email protected]>
Newsgroups gmane.comp.web.webobjects.wonder-disc
Message-ID <[email protected]>
On 2013-03-08, at 2:30 PM, Ramsey Gurley wrote:
> On Mar 8, 2013, at 3:21 PM, Ramsey Gurley wrote:
>> On Mar 8, 2013, at 3:07 PM, Chuck Hill wrote:
>>> On 2013-03-08, at 2:02 PM, Ramsey Gurley wrote:
>>>> 
>>>> So I'm reading EOFetchSpec's javadoc for refreshing on fetch and I see:
>>>> 
>>>> "For example, suppose that an employee object is fetched and then refetched, without changing the employee between fetches. In this case you want to refresh the employee when you refetch it because another application might have updated the object since the first fetch. To keep the employee in sync with the employee data in the external repository you would need to replace the employee's outdated values with the new ones. On the other hand, if you have to fetch the employee, change it, and then refetch it, you would not want to refresh the employee. If you are to refresh it whether or not another application had changed the employee you would lose the changes that you have made to the object."
>>>> 
>>>> However when I actually try this in Freshness Explorer, that is not what happens. If I fetch John Smith, change his name to Travis, then submit and [Fetch One EO] with the [x]refresh checkbox checked, it stays Travis in the EC.
>>>> 
>>>> It seems rather silly to go to the database, fetch rows, and then ignore those fresh values in favor of some stale snapshots hanging around. :-/
>>> 
>>> You prefer to erase the user's unsaved changes?  
>> 
>> That's the thing, it doesn't erase the changes. The changes stay in place and only the values the user hasn't touched get updated (assuming they changed).

Yes, that is exactly what the documentation states:

>>>> if you have to fetch the employee, change it, and then refetch it, you would not want to refresh the employee. If you are to refresh it whether or not another application had changed the employee you would lose the changes that you have made to the object.


> I have a copy of Freshness Explorer here if you want to see what I mean

I know how it works.  :-)  Maybe it is just Friday, but you seem to be complaining that the behaviour matches the documention.  I know that this is not always the case :-P but here it is.

If you DON'T want that behaviour, you can implement the EC delegate method below.  "If this method returns false, no uncommitted changes are applied. Thus, the object is updated to reflect the values from the database exactly. This method should not make any changes to the object since it is about to be invalidated."

Chuck


> 
> https://github.com/nullterminated/ponder/blob/master/ERR2d2w/Support/FreshnessExplorer.zip
> 
>> 
>>> You need an EC delegate, see the method:
>>> 
>>> boolean editingContextShouldMergeChangesForObject(EOEditingContext context, EOEnterpriseObject object)
>>> 
>>> 
>>> Chuck
>>> 
>>> -- 
>>> Chuck Hill             
>>> Executive Managing Partner, VP Development and Technical Services
>>> 
>>> 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/gvc/practical_webobjects
>>> 
>>> Global Village Consulting ranks 13th in 2012 in BIV's Top 100 Fastest Growing Companies in B.C! 
>>> Global Village Consulting ranks 76th in 24th annual PROFIT 200 ranking of Canada’s Fastest-Growing Companies by PROFIT Magazine!
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>> 
> 

-- 
Chuck Hill             
Executive Managing Partner, VP Development and Technical Services

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/gvc/practical_webobjects

Global Village Consulting ranks 13th in 2012 in BIV's Top 100 Fastest Growing Companies in B.C! 
Global Village Consulting ranks 76th in 24th annual PROFIT 200 ranking of Canada’s Fastest-Growing Companies by PROFIT Magazine!












------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.