Is there a way to dynamically create a selectItem list? I dont really want to have to create lots of bean code to make my lists return List
.
Use <f:selectItems>
instead. It accepts next to List<SelectItem>
and SelectItem[]
also a Map<String, Object>
as value where the map key is the item label and map value is the item value. Or if you're already on JSF 2.0, then you can use a List<SomeBean>
instead where the current item can be referenced by the var
attribute.
<f:selectItems value="#{productListingService.list}" var="product"
itemLabel="#{product.description}" itemValue="#{product.id}" />