Saturday, March 3, 2007

No more pain in constructing collections of SelectItem's

It's been some time before I noticed something in Seam that I should have noticed long time ago... Ever experienced pain converting results of your queries into collections of Collection<SelectItem> just to show them in, for example <h:selectOneMenu>? Well this pain may be over with Seam (starting from version 1.1.5 I think) now supporting the following tag: <s:selectItems>.

What it does is it creates a collection of SelectItem (List<SelectItem>) from your List, Set, DataModel or Array. For the list of attributes refer to the reference documentation and the "ui" example of seam which is included in the Seam distribution (can be found in "examples/ui")