Adding an Object to an Array that doesn't exist in database
Adding an Object to an Array that doesn't exist in database
- Subject: Adding an Object to an Array that doesn't exist in database
- From: Dev WO <email@hidden>
- Date: Thu, 26 May 2005 00:36:41 +0200
Hi guys,
I don't know if I'm going to the right direction, but here's what I
have:
I've got an Item that has (among other things) a popup menu that lists
OtherItems' name available in a table (this is to register the father
of the item).
What I wanted to do is to add another "virtual" name in this popup menu
to allow choosing "none".
So I created another instance of Item called "unavailable" and added it
to the beginning of the array:
itemList.insertObjectAtIndex(unavailable, 0);
So this seems to work and I've got an new item of the beginning of the
father's popup menu with "unavailable".
Then here's the part I've a problem with:
I'd like to add (or update) an Item, and I'd like to keep the
item.fatherName to NULL if "unavailable" is selected and the correct
item if a "real" father is selected.
But when I'm trying to save, I got a crash complaining about an object
which isn't in the editing context...
here's my save method:
public WOComponent addOrUpdateItem()
{
if (!itemList.containsObject(item))
{
// checking if unavailable is selected
if (item.itemName().equals("Unavailable"))
{
// setting the item father's name to NULL
item.setItemName("");
}
itemList.addObject(item);
ec.insertObject(item);
awakeFromInsertion(ec);
item = new Item();
}
else
{
awakeFromInsertion(ec);
item = new Item();
editMode = false;
}
ec.saveChanges();
return null;
}
So maybe there's an easier way to handle that;)
What I am thinking is that I should probably store the "selection" of
the WOPopupMenu to something else than directly item.itemFather and
then evaluate the value of this new object...
Could anyone provide me with a tip (or 2;))
Thanks a lot
Xavier
_______________________________________________
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