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: Robert Walker <email@hidden>
- Date: Thu, 11 Dec 2003 19:31:27 -0500
Deirdre,
If I understand your problem correctly here is what I would do:
Instead of creating a fourth attribute (tsDescrip) on TimeSlot I would
just write a simple business method on the TimeSlot class.
1. In the model change TimeSlot's Class from EOGenericRecord to
TimeSlot (or something like com.myapp.TimeSlot) and generate the class
file (Note: Most people prefer using a code generator for this, but
using EOModler's class generator along with FileMerge will work as
well).
2. Add the business method like this:
public class TimeSlot extends EOGenericRecord() {
//Constructor
public TimeSlot() {
super();
}
//Here is the business method
public String tsDescrip() {
//You may want to use NSTimestamp's formatter if your times are
instances
//of NSTimestamp and you want a format other than what toString
provides.
return startTime().toString + " " + endTime().toString() + " " +
toDayNames.dayName();
}
...
the getters and setters will follow here
Using this method there is no need to update anything since tsDescrip()
will always return the concatenation of the current values of
startTime, endTime and toDayNames.dayName(). The class browser in
WOBuilder will recognize tsDescrip as just another attribute of the
entity so you can bind it to WOString or any other element in the page.
On Dec 11, 2003, at 12:28 AM, 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.
--
Sincerely,
Robert Walker
_______________________________________________
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.