Re: Setting a Default toOne Relationship
Re: Setting a Default toOne Relationship
- Subject: Re: Setting a Default toOne Relationship
- From: Wolfram Stebel <email@hidden>
- Date: Fri, 19 May 2006 00:06:49 +0200
- Thread-topic: Setting a Default toOne Relationship
Am 18.05.2006 23:06 Uhr schrieb "David Avendasora" unter
<email@hidden>:
> You see, I knew I was missing something obvious. And here I was
> trying to override the setter for the relationship. Nothing like
> trying to do it the hard way.
And after all this good tips, you might think about factory methods for each
class like this:
public static MyClass newMyClassForYourRelatedEOs ( EOEditingContext ec,
MultipleParameter myRelatedEOs )
{
MyClass newObject = new MyClass ( ec );
// set your initial relationships
newObject.addObjectToBothSidesOfRelationshipWithKey ( myRelatedEO1,
"myRelation1" );
newObject.addObjectToBothSidesOfRelationshipWithKey ( myRelatedEO2,
"myRelation2" );
//
return newObject;
}
The final setup can follow here:
public void awakeFromInsertion ( EOEditingContext ec )
{
super.awakeFromInsertion ( ec );
// set your initial values
}
Validating might be a nice idea too:
public void validateForSave () throws NSValidation.ValidationException
{
// do your validation first (i prefer this, because super.validateForSave
returns always english error messages, so i try to validate before super and
display my own colloquial)
super.validateForSave ();
// or do your validation last for all remaining errors
}
HTH
Wolfram
_______________________________________________
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