Re: WOPopUpButton - list & selection not working
Re: WOPopUpButton - list & selection not working
- Subject: Re: WOPopUpButton - list & selection not working
- From: Art Isbell <email@hidden>
- Date: Wed, 19 Feb 2003 21:44:22 -1000
On Wednesday, February 19, 2003, at 06:31 PM, Thomas Peters wrote:
I have products and categories, where categories is a parent object to
products. Category is defiled as a category_id and a category_name.
The stored
value is category_id and the displayed value is category_name.
I can't seem to get the bindings right for this, or I just do not
understand
how it works. I have set the list binding to an NSArray containing the
categories. I have set the selection to the product.category_id.
The popup button's "list" is an array of categories, so "selection"
must be one category, yet you've defined "selection" to be
product.category_id which is likely an integer, not a category. Hence
the exception.
It sounds like you're still trapped thinking in terms of relational
databases, not objects. product.category_id sounds like the foreign
key for the relationship product.category. Primary and foreign keys
should not generally be class properties, so you shouldn't even be able
to bind product.category_id to anything. But you should be able to
bind the product.category relationship, a class property, to
"selection". And that's what you should do if you're using the popup
button to set the product.category value.
A popup button isn't able to display a category object very well, so
you probably want to display category.category_name. To do that,
you'll need to create an instance variable of type Category named
something like "categoryItem". Bind that to "item". Bind
"displayString" to categoryItem.category_name.
By the way, it's best to follow Java identifier naming conventions
with your attribute and relationship names. So if the database column
name is "category_name", the attribute name would be "categoryName".
Art
http://homepage.mac.com/aisbell/
_______________________________________________
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.