Le 2012-02-07 à 20:23, Chuck Hill a écrit :

> Hi Pascal,
> 
> On 2012-02-07, at 12:39 PM, Pascal Robert wrote:
> 
>> Hi guys,
>> 
>> I have a problem with an editing context, look like it's a delay when I 
>> delete objects (objects that are not yet in the database). So in short, 
>> people create transactions (not database transactions) when they add items 
>> to a job (just like when you add stuff in a shopping cart) and can decide to 
>> remove a transaction from the job. When they remove an item from the job, I 
>> do:
>> 
>>   rootTransaction.deleteSubTransactionsRelationship(transactionItem);
> 
> Does this do the same thing as removeObjectFromBothSides...  ?
> 
> 
>>   editingContext().deleteObject(transactionItem);
> 
> That does very little until editingContext().processRecentChanges() is called.

Manually calling processRecentChanges fixed my issue.

Thanks Chuck.

> 
>> But when the page reload (by a Ajax call), the list of available items is 
>> not updated. Example:
>> 
>> - I have Item 1 and Item 2 available to put in the job
>> 
>> - I add Item 1 to the job, it's not available to pick up, that's what I want
>> - I add Item 2 to the job, it's not available to pick up, that's what I want
>> 
>> - I remove Item 1 from the job, so that's calling the deleteObject() and  
>> deleteSubTransactionsRelationship() methods. Item 1 disappears from the job 
>> (ok), but it's not available for picking up (bad).
>> 
>> - I remove Item 2 from the job, and now Item 1 is available for pickup! But 
>> Item 2 is still not available, until I do a revert on the editing context 
>> and redo the steps.
> 
> Sounds like a processRecentChanges() problem, or your code is not adding it 
> back to the available list right away?
> 
> 
>> If I print editingContext().deletedObjects() after the call to  
>> editingContext().deleteObject(transactionItem), I see that the item (Item 2) 
>> I'm removing is in the array. If I print it again when I delete I ten 2, the 
>> only object in  editingContext().deletedObjects() is Item 2, Item 1 is not 
>> in it anymore.
>> 
>> So the question: is there some kind of delay when you delete an object in 
>> the EC and just after you use a relationship (the relationship is for 
>> finding the available items)?
> 
> deleteObject() does not do much other than record that the object is to be 
> deleted.  Also, could you be calling saveChanges() at some point?
> 
> 
> -- 
> Chuck Hill             Senior Consultant / VP Development
> 
> 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 protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to