Re: set the "sourceObject" to an EO ??
Re: set the "sourceObject" to an EO ??
- Subject: Re: set the "sourceObject" to an EO ??
- From: David Holt <email@hidden>
- Date: Fri, 27 Jul 2012 06:44:17 -0700
Also if you have an entity named "Project" and another named "ProjectCategory" you may need to distinguish them for D2W with different priority rules.
http://davidleber.net/?p=273
Sent from my iPad
On 2012-07-27, at 6:31 AM, Theodore Petrosky <email@hidden> wrote:
> I am trying to use ERXThreadStorage to copy an EO relationship into a newly created EO.
>
> in my MainNavigatorController I have a method:
>
>
> public WOComponent listSaleAdsProjectsAction() {
>
> NSLog.out.appendln("*** listSaleAdsProjectsAction *****" );
> ERXEC ec = (ERXEC) (session().user().editingContext());
> ProjectCategory theCat = ProjectCategory.fetchProjectCategory(ec, ProjectCategory.CATEGORY_TITLE.eq("Sale Ads"));
>
> ((Session) session()).setCurrentCategory(theCat);
>
> ListPageInterface lpi = (ListPageInterface) D2W.factory().pageForConfigurationNamed("ListSaleAdProjects", session());
> EODataSource ds = new EODatabaseDataSource(ec, "Project");
>
>
>
> // limit the blog entries returned to the logged in user
> ds.qualifyWithRelationshipKey("projects", theCat);
>
> lpi.setDataSource(ds);
>
> return (D2WPage) lpi;
> }
>
> so the current category in set in the session:
>
>
> public void setCurrentCategory(ProjectCategory theCat) {
> this._currentProjectCategory = theCat;
> NSLog.out.appendln("***setCurrentCategory: " + theCat);
>
> ERXThreadStorage.takeValueForKey(theCat, "currentProjectCategory");
>
> NSLog.out.appendln("***after setCurrentCategory: " + ERXThreadStorage.valueForKey("currentProjectCategory"));
>
> }
>
> in my init method of my Project object:
>
> public void init(EOEditingContext ec) {
> super.init(ec);
> NSLog.out.appendln(" initing the Project EO " );
> NSLog.out.appendln(" initing the Project EO " + ERXThreadStorage.valueForKey("currentProjectCategory"));
>
> ProjectCategory currentaCat = ((ProjectCategory) ERXThreadStorage.valueForKey("currentProjectCategory")).localInstanceIn(ec);
> setProjectCategoryRelationship(currentaCat);
>
> NSLog.out.appendln(" initing the Project EO this.projectCategory().categoryTitle() " + this.projectCategory().categoryTitle());
>
> }
>
> I know that the ERXThreadStorage valueForKey is correct, however I get the error:
>
> Destination entity could not be retrieved from EO of bindings. Either set the "sourceObject" to an EO, provide the "sourceEntityName" and "relationshipKey", the "destinationEntityName" or the "possibleChoices" binding.
>
> Help please!!
> I don't understand what bindings I need to make, or rather I don't understand how to make these bindings.
>
> Ted
>
>
> _______________________________________________
> 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
_______________________________________________
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