Re: newbie q: multiple fields insertion?
Re: newbie q: multiple fields insertion?
- Subject: Re: newbie q: multiple fields insertion?
- From: Jean-François Veillette <email@hidden>
- Date: Thu, 24 Nov 2005 13:15:01 -0500
Instead of having multiple attributes, just keep one, a
NSKeyValueCoding.
like :
// in the form entry component :
NSKeyValueCoding entry;
EOEditingContext ctx; // keep a local reference, ctx might point to
session.defaultEditingContext, might point to a sibling editing context
or mignt point to a child editing context.
// you set all your binding to entry as if it where a real BlogEntry
(entry.title, entry.name, etc.).
That way, you can use the form entry component
- and pass it a wodisplaygroup.queryDict to use the form in a query by
example page.
- and pass it a BlogEntry, to edit already created object
- and pass it a NSMutableDictionary and 'maybe' insert a new object
depending on some action, value provided or some validations (use
takeValuesFromDictionary(..) to push values into your EO).
I vaguely remember a similar question on this list, it was ask which
edit/insertion pattern people where using.
- jfv
On 24-Nov-05, at 11:37 AM, Jeremy Matthews wrote:
Following this example is easy:
public WOComponent createBlogEntryAction()
{
EOEditingContext ec = session().defaultEditingContext();
EOEnterpriseObject newEntry =
EOUtilities.createAndInsertInstance(ec, "BlogEntry");
newEntry.takeValueForKey(title, "title");
newEntry.takeValueForKey(body, "body");
newTitle = newBody = null;
ec.saveChanges();
return null;
}
However, I don't want to create a dozen single keys in WOBuilder, and
I'd rather create a key that references the Entity, so I can easily
drag its attributes to the correct fields. So, I created a new key
"newEntry" and made it of type "BlogEntry" (which is the entity that
includes title and body), instead of a bunch of independent strings.
This creation showed a key with references to all the attributes in
that entity.
However, I'm a bit confused as to how to replace these lines:
newEntry.takeValueForKey(title, "title");
newEntry.takeValueForKey(body, "body");
Since it no longer works, as those references now point to:
newEntry.title
newEntry.body
I've tried replacing title for newEntry.title (and the body attribute
as well), but it doesn't work.
What does?
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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