tags:

views:

3516

answers:

1

I am having an issue in creating rich:combobox i did as follows

<rich:comboBox selectFirstOnUpdate="false" defaultLabel="Enter some value">
    <f:selectItems value="#{userregister.selectItems}" />
</rich:comboBox>

and in the backing bean i created the selectItems as follows

 List<UISelectItem> selectItems;
 UISelectItem uisi = new UISelectItem();
 uisi.setItemLabel("label");
 uisi.setValue("value");
 selectItems.add(uisi);

But i am getting the exception javax.servlet.ServletException: Value of tag <selectItems> attribute is incorrect. Which the proper way to create a combobox with dynamic values ?

+1  A: 

The reason its not working is because you havent set itemValue on your select item. However Ive never used UISelectItem and instead used SelectItem like this:

List<SelectItem> selectItems = new ArrayList();
selectItems.add(new SelectItem('value', 
'label'));

which is the same as saying:

List<SelectItem> selectItems = new ArrayList();
SelectItem item = new SelectItem();
item.setItemLabel("label");
item.setItemValue("value");

The value for the selectItem is defined as itemValue not value btw so by correcting that your code will probably work without any modifications other than that. Any reason your using UISelectItem and not just SelectItem btw?

ChrisAD