如何动态创建<f:selectItem>列表?

DD.*_*DD. 16 jsf icefaces

有没有办法动态创建selectItem列表?我真的不想创建大量的bean代码来让我的列表返回List<SelectItem>.

我试过这个:

<ice:selectManyCheckbox>
    <ui:repeat var="product" value="#{productListingService.list}">
      <f:selectItem itemLabel="#{product.description}" value="#{product.id}"/>
    </ui:repeat>
</ice:selectManyCheckbox>
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

有任何想法吗?

Bal*_*usC 30

<f:selectItems>改用.它接受旁边的List<SelectItem>SelectItem[]一个Map<String, Object>as值,其中map键是item标签,map值是item值.或者,如果您已经在JSF 2.0上,那么您可以使用List<SomeBean>替代,其中var属性可以引用当前项.

<f:selectItems value="#{productListingService.list}" var="product" 
    itemLabel="#{product.description}" itemValue="#{product.id}" />
Run Code Online (Sandbox Code Playgroud)

也可以看看: