Re: Concatenating two fields into yet another field
Re: Concatenating two fields into yet another field
- Subject: Re: Concatenating two fields into yet another field
- From: Chuck Hill <email@hidden>
- Date: Wed, 10 Dec 2003 21:48:26 -0800
It is usually a good idea to avoid using EOGenericObject directly if the
object needs behaviour. EOGenericRecord is fine for modeling join tables
and such but is best avoided for real work. If you really must, then
something like this:
timeSlot.takeValueForKey(timeslot.valueForKey("startTime"), "tsDescrip ");
If you use a sub-class of EOGenericRecord you have a few options:
One way would be to override setStartTime() etc. to update the value as
they do now and then call updateDescription(). This is particularly easy
if you are using EOGenerator and the Generation Gap pattern. Otherwise you
end up modifying generated code and that is never a good thing.
Another way is to use one of the Editing context sub-classes that notify
their eo object about changes. Then put the logic in a method that is
called before saveChanges() is invoked. I think I've also seen a EC
delegate way to do at least some of this. I don't have any links handy but
I'm certain that there is one in Project WOnder -- if you can find it. You
can probably also find on www.wodev.com or www.wocode.com.
The wrong way is to update this in validateForSave. That may work to begin
with, but it will bite you in the end.
Chuck
At 09:28 PM 10/12/2003 -0800, Deirdre Saoirse Moen wrote:
>This seems like it should be simpler than it is, but I'm clearly
>missing something.
>
>I have an object, timeSlot, that is an EOGenericRecord. The record it
>points to has three fields I want to manipulate and concatenate
>(startTime, endTime, toDayNames.dayName) into a fourth field
>(tsDescrip) before I call
>
>editingContext.saveChanges();
>
>Catch is, it seems like it should logically go into the add/update
>button scripts (e.g. updateTimeSlot), but what I've tried hasn't worked.
>
>So I'm having a conceptual failure about what I need to do. I've looked
>around, but haven't found anything that seemed helpful.
>
> timeSlot.tsDescrip = timeSlot.startTime;
>
>...isn't right. But how do I approach this?
>
>--
>_Deirdre http://deirdre.net
>"Cannot run out of time. There is infinite time. You are finite.
>Zathras is finite. This....is wrong tool." -- Zathras
>_______________________________________________
>webobjects-dev mailing list | email@hidden
>Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
>Do not post admin requests to the list. They will be ignored.
>
--
Chuck Hill email@hidden
Global Village Consulting Inc. http://www.global-village.net
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.