• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Adding an Object to an Array that doesn't exist in database
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding an Object to an Array that doesn't exist in database


  • Subject: Re: Adding an Object to an Array that doesn't exist in database
  • From: Mark Morris <email@hidden>
  • Date: Wed, 25 May 2005 17:47:28 -0500

There's a checkbox in the WO popup component for setting the string to display to correspond with NULL. Just set that, and I think you'll have exactly the behavior you're looking for. ;-)

Regards,
Mark

On May 25, 2005, at 5:36 PM, Dev WO wrote:

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:
email@hidden


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
References: 
 >Adding an Object to an Array that doesn't exist in database (From: Dev WO <email@hidden>)

  • Prev by Date: Re: Adding an Object to an Array that doesn't exist in database
  • Next by Date: Re: Adding an Object to an Array that doesn't exist in database
  • Previous by thread: Re: Adding an Object to an Array that doesn't exist in database
  • Next by thread: Re: Adding an Object to an Array that doesn't exist in database
  • Index(es):
    • Date
    • Thread