Re: duplicating an EO
Re: duplicating an EO
- Subject: Re: duplicating an EO
- From: David Avendasora <email@hidden>
- Date: Mon, 21 Mar 2011 06:26:21 -0400
Hi Ted,
The link for PWO at Apress' site is: http://apress.com/book/view/9781590592960
You can buy an eBook version of it there, which is spendy, but worth it to always have it at your fingertips. Chuck really wouldn't mind you buying it _3_ times... :-)
There is also a link on that page to download the sourcecode related to the book. In there, in one of the chapters (I can't remember which one right now as I haven't bought the eBook =:-0 ) you'll find the source code for what you'd need in an EOCopyable interface and what methods you should add to your custom sublcass of EOGenericRecord.
You do have a custom subclass of EOGenericRecord, right?!
Good luck. The book is key to understanding what the source code is doing. Implementing Chuck's EOCopyable functionality will probably take you marginally longer than just manually doing the duplicating _this time_ but once you set it up, it's available on all EOs and it is _very_ cool.
I'm amazed that this hasn't made its way into WOnder yet... well maybe people still need a reason to buy Chuck's book. I mean, with all the other really excellent WO books out there...
Oh wait...
Dave
On Mar 20, 2011, at 6:24 PM, Theodore Petrosky wrote:
> I have two copies of that book. I thought one at home and one in the office. I guess I have to wait till tomorrow at the office to read up.
>
> thanks
>
> Ted
>
> --- On Sun, 3/20/11, David LeBer <email@hidden> wrote:
>
>> From: David LeBer <email@hidden>
>> Subject: Re: duplicating an EO
>> To: "Theodore Petrosky" <email@hidden>
>> Cc: email@hidden
>> Date: Sunday, March 20, 2011, 5:39 PM
>>
>> On 2011-03-20, at 4:59 PM, Theodore Petrosky wrote:
>>
>>> I have a rather simple object. it has about 15
>> attributes. My users have informed me that they need a way
>> to insert 25 duplicates of this object. Obviously they go in
>> and change the due date (or some other attribute) of the
>> duplicates. this is the only change.
>>>
>>> so i gave them a simple popup with the numbers 1 to 25
>> and they can choose how many of these things they want.
>>>
>>> what would be the easiest and bestest way to dup these
>> objects. I started thinking to create a loop that iterates
>> the number of times that they want and insert a new EO into
>> the EC and copy the attributes from my master object.
>>>
>>> But maybe there is an easier way?
>>>
>>> I hope I am explaining it simply enough
>>
>>
>> Practical WebObjects has a great chapter on EO copying.
>>
>> Unfortunately it is a subject that can eat an entire
>> chapter. Duplicating only the attributes is easy, you can
>> just ask the existing EO for it's entity, ask the entity for
>> it's attributes, and then iterate through them calling
>> setValueForKey on the new EO with valueForKey on the
>> existing one. However when you get into relationships things
>> become much more difficult to handle in a generic way (i.e:
>> do you want to copy the destination EOs or just the
>> relationships, do you want to copy the relationships of the
>> destination EOs, etc).
>>
>> Anyway, the chapter in Chuck's book is well worth the
>> read.
>>
>> ;david
>>
>> --
>> David LeBer
>> Codeferous Software
>> 'co-def-er-ous' adj. Literally 'code-bearing'
>> site: http://codeferous.com
>> blog: http://davidleber.net
>> profile: http://www.linkedin.com/in/davidleber
>> twitter: http://twitter.com/rebeld
>> --
>> Toronto Area Cocoa / WebObjects developers group:
>> http://tacow.org
>>
>>
>>
>>
>>
>
>
>
> _______________________________________________
> 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