0

I have there code

<p:selectOneMenu id="starter" value="#{reportRegisterManagedBean.starter}" style="width:160px" converter="#{reportStarterConverter}">
<f:selectItem itemLabel="Select Report Starter" itemValue="0"
itemDescription="TEST" />
<f:selectItems
value="#{reportRegisterManagedBean.startersSelectItems}" var="ds" itemLabel="#{ds.name}" itemValue="#{ds}" itemDescription="#{ds.description}" />
</p:selectOneMenu>

here itemDescription="TEST" atribute works very well in <f:selectItem> tag. but itemDescription="#{ds.description}" not working in <f:selectItems> tag.

is here bug?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
zura katsitadze
  • 307
  • 2
  • 6
  • 15

1 Answers1

1

f:selectItems requires a List which you define in our bean like this:

List<SelectItem> list = new LinkedList<SelectItem>();
list.add(new SelectItem("this will be the return value -> itemValue", "this will be the display value -> itemLable"));

If you do so, you don't even need itemValue or itemDescription, because it's already defined in the list.

Update(note: you don't need itemValue, itemDescription):

In your xhtml page it would look like this:

<p:selectOneMenu value="#{reportRegisterManagedBean.starter}">
    <f:selectItems value="#{reportRegisterManagedBean.startersSelectItems}" />
</p:selectOneMenu>
leostiw
  • 1,125
  • 3
  • 12
  • 28
  • I have startersSelectItems = new ArrayList(); startersSelectItems.add(new SelectItem(ds, ds.getName())); i try to use ds.getName() to show itemDescription="#{ds.name}" but not working – zura katsitadze Mar 25 '13 at 12:02
  • Did you remove itemDescription, itemLabel from your f:selectItems tag? I updated my answer, try it. – leostiw Mar 25 '13 at 14:14
  • no, i have converter and other attribute in . is any difference between new LinkedList() and new ArrayList()? – zura katsitadze Mar 25 '13 at 16:59