Re: Want to iterate over items in EditingContext for validation before save
Re: Want to iterate over items in EditingContext for validation before save
- Subject: Re: Want to iterate over items in EditingContext for validation before save
- From: WebObjects <email@hidden>
- Date: Tue, 02 May 2006 19:01:15 -0700
- Thread-topic: Want to iterate over items in EditingContext for validation before save
Art,
I'm thinking of EOEditingContext.insertedObjects() as the choice in this
case. I actually thought that may be the answer here (thanks for your time
on this).
If I were to remove an element of the NSArray returned by this method, would
then calling .saveChanges() on the ec now exclude objects removed from the
array? If so is this because of the magic of WO keeping track of things?
(it seems to easy, like I'm missing something)
Thanks for your wisdom,
-Bill
on 5/2/06 18:53, Art Isbell at email@hidden wrote:
> On May 2, 2006, at 2:48 PM, WebObjects wrote:
>
>> I've found an error in my coding style - too late in this project
>> though. I
>> use EOUtilities.createAndInsertInstance in a constructor for a
>> page, and as
>> a result 'refresh' and 'back' have become my enemies.
>>
>> How can I iterated over the unsaved objects in an EditingContext
>> (ec), test
>> their validity (ie. if ItemAt(0).getSomeValue() == null, etc) and
>> delete
>> them from the ec prior to .saveChanges() ?
>
> It would seem that if you can modify your code to iterate over
> unsaved objects, that you could also modify your constructor to fix
> this problem. But maybe not...
>
> EOEditingContext.insertedObjects() returns an array of inserted
> objects.
>
> Or probably better, assuming that you can modify your constructor,
> would be to create a new editing context assigned to an instance
> variable of this component, lock it, and insert your new objects into
> this new editing context. Then if the user backtracks or refreshes,
> only objects inserted into the editing context of the current
> instance of this component would be saved. Objects inserted into
> other instances of the same component would be freed when the
> component drops out of the page cache without being saved to the DB.
>
> Aloha,
> Art
>
> _______________________________________________
> 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
_______________________________________________
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