Creating a combobox in Richfaces
I have a problem creating rich: combobox I did the following:
<rich:comboBox selectFirstOnUpdate="false" defaultLabel="Enter some value">
<f:selectItems value="#{userregister.selectItems}" />
</rich:comboBox>
and in the bean base I created selectItems as follows
List<UISelectItem> selectItems;
UISelectItem uisi = new UISelectItem();
uisi.setItemLabel("label");
uisi.setValue("value");
selectItems.add(uisi);
But I am getting an exception javax.servlet.ServletException: Value of tag <selectItems> attribute is incorrect.
What is the correct way to create a combobox with dynamic values?
+2
source to share
1 answer
The reason it doesn't work is because you didn't specify itemValue on your select element. 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 selectItem is defined as itemValue not value btw so fixing that your code will probably work without any changes other than that. Any reason why you are using UISelectItem and not just SelectItem btw?
+4
source to share