Re: why does selecting a parent not make me it's child?
Re: why does selecting a parent not make me it's child?
- Subject: Re: why does selecting a parent not make me it's child?
- From: Chuck Hill <email@hidden>
- Date: Mon, 14 Jul 2003 08:00:43 -0700
This is because your code is only setting one half of the relationship and
not calling addObjectToBothSideOfRelationshipWithKey. The
WOToOneRelationship might be useful to you here. Otherwise you can:
1. Roll your own version of WOToOneRelationship that does what you want.
2. Add cover methods in the page to do it
3. Add cover methods in the object to do it (e.g.
currentParent()/setCurrentParent() )
Chuck
At 04:34 PM 14/07/2003 +1200, Denis Stanton wrote:
>I hope someone can put me straight here. Maybe I'm expecting too much,
>or maybe I'm overlooking the obvious.
>
>I have two entities with a one to many relationship. For arguments
>sake they can be classes Parent and Child
>
>I have an editing WOComponent containing a WOForm allowing me to change
>any of the fields for myChild, an instance of Child
>
>One of the objects in the WOForm is a PopUpButton that lists all
>available instances of Parent, as previosuly loaded into NSMutableArray
>parentArray
>
>PopUpButton1: WOPopUpButton {
> displayString = parentItem.name;
> item = parentItem;
> list = parentArray;
> noSelectionString = noParent;
> selection = child.parent;
>}
>
>If I use this pop up to chose a different parent, and then click
>Submit, which saves the changes, the child now has a new parent.
>
>Unfortunately the same page also lists all the parents and the children
>for each. After performing the above operation I see that two parents
>are now claiming the child. The child appears to be a member of the
>array oldParent.childs() and also of newParent.childs() (apologies for
>the odd grammar)
>
>If I restart my application (I'm working in dev mode) it would appear
>that EOF recalculates oldParent.childs() array, correctly omitting the
>Child that has been moved. Obviously this is not the best way to
>update the data display.
>
>Is there an easier way to remove the child from oldParent.childs() ?
>The above editing operation does not require me to write any java code
>to change the child -> parent relationship. If I have to remove the
>child from one parent and add it to another manually I will have to
>keep some separate record of the previous parent. It's starting to
>look messy, and in my experience messy code usually means I just
>haven't understood how to do something properly.
>
>Thank for your kind attention in reading this far
>
>Denis
>_______________________________________________
>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.
>
--
Chuck Hill email@hidden
Global Village Consulting Inc. http://www.global-village.net
_______________________________________________
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.