[Seaside] Can I do this with a select list?

Rick Flower rickf at ca-flower.com
Fri Oct 6 05:27:57 UTC 2006


I've got a collection of objects that are read in from a database and
I'd like to be able for Seaside to use that collection (which will be
used elsewhere as well) to build a list of stuff to show up in a select
list -- specifically labels of my own choosing (based on the database
objects read in).  So, if I've got some objects with a #name instance
variable in them (among other things), I'd like to be able to do 
something like the following :

"Read the items from the database -- this returns full objects"
| catCollection |
catCollection := self readDBItems.
.
.
.
(html select) list: catCollection; useMappingMethod: #name; selected: (catCollection first); callback: [:i | self cat: i].
.
.
.

Right now, I have code that massages my "catCollection" and extracts
out the #name from each object and populates an Array which is used for
the #list: and #selected: messages.  Unfortunately, this gets ugly 
with the callback where I have to take the selected string and do a 
reverse lookup from the collection to get the actual object which is 
what I'm interested in saving.  

I looked at the code for WACollectionTag, but didn't see anything in 
there that would support this sort of mechanism..  I'd love to have 
the ability to register a method (care of the above #useMappingMethod:)
that can be called for each item in the collection to obtain the string 
that the select list needs.. On the other hand, when the callback is called, 
instead of returning the selected string as the argument to the callback, 
it would return the entire selected object..

Has anyone else needed to do something like this, or is there some easier
way to achieve this without doing the to/from translations?

Thanks!


More information about the Seaside mailing list