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: Deirdre Saoirse Moen <email@hidden>
- Date: Thu, 11 Dec 2003 00:14:33 -0800
On Wednesday, December 10, 2003, at 09:48 PM, Chuck Hill wrote:
Chuck, thanks for the quick reply.
It is usually a good idea to avoid using EOGenericObject directly if
the
object needs behaviour.
Yes, in most cases that'll work OK for what I'm doing, however.
I'd completely forgotten about the data being key/value pairs, in part
because I'd been working in other paradigms for a while. Doh!
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
");
public EOGenericRecord timeSlot;
...
public String timeSlotText()
{
String startTime, endTime;
startTime = timeSlot.valueForkey("startTime");
...
}
Gives the error:"cannot resolve symbol : method valueForKey
(java.lang.String)
..which is weird, because timeSlot *is* an EOGenericRecord and that
should be a valid method.
Now, there's few enough records, and there's virtually no maintenance,
that it's no real sin if this isn't easy, because it'd be ten minutes
to do it in mysql directly. But, I'd rather learn something about WO in
the process.
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.
Yes, I'd been looking into that, but hadn't wanted to go there yet if I
didn't have to with this project. This is really the only slick bit I
need to do. This has a complex data model, but not oodles of data, and
it's a volunteer project.
Otherwise you
end up modifying generated code and that is never a good thing.
True.
Another way is to use one of the Editing context sub-classes that
notify
their eo object about changes.
If this were something that was being used by more people or was more
complicated, I'd go through this, but it's really overkill for this
project. I think. :)
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.
Good point.
--
_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.