[Seaside] Usage of Canvas' #select and #labels
Philippe Marschall
philippe.marschall at gmail.com
Fri Apr 6 19:31:06 UTC 2007
2007/4/6, Rick Flower <rickf at ca-flower.com>:
> Hi all..
>
> I'm trying to find a way to cleanup some of my existing code. I've got,
> in a handful of places, items coming out of a Glorpified database and
> use this data as the items in various Canvas API #select lists for
> various forms I've got.
>
> What I currently do is prepend an item to the front of the select array
> when the component is initially drawn by Seaside that has text similar
> to "Select one...".. I've got code that will take the array that I
> get back from Glorp and add a nil item to the front of the array that I
> can then check for in the labels: code block -- if the item being
> processed is nil, then I make the label say 'Select one...', otherwise
> use the database data.. Below is the code I use more or less to
> achieve this :
>
> html select list: orgs ;
> callback: [:i | self orgId: i];
> labels: [:org | org = '' ifTrue: [ 'Select One..' ] ifFalse: [ org name ] ].
>
> Does anyone use anything more elegant to overcome this or is everyone
> selecting their data directly from the database items without the need
> for a 'select one...' initially selected label? I'd love to ditch the code
> I've got that has to manipulate the array I get from Glorp along with the
> extra code to fiddle w/ Seaside labels to do what I want..
>
> I guess I could take a stab at writing up a modification to the Canvas
> API's #select method that takes an #initiallySelectedLabel: method call
> to set the name for that initially selected label item -- would anyone
> else find that useful? Perhaps the result would allow for something like
> the following:
>
> html select list: orgs ;
> callback: [:i | self orgId: i];
> labels: [:org | org name ];
> initiallySelectedLabel: 'Select One...'.
>
> Comments?
html select
beOptional
list: orgs;
on: #orgId of: self;
"You can use #name if you implement #value in Symbol
You can leave this out of you implement #displayString or
#renderOn. in your domain class"
labels: [:org | org name ];
optionalLabel: 'Select One...'.
Philippe
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
More information about the Seaside
mailing list