Search code examples
javajsficefaces

Populating IceFaces HtmlSelectOneListbox when not using xhtml


I am implementing comboboxes in an application where IceFaces forms are being built dynamically. There are no xhtmls around, we put together everything from Java code. This works nice so far, but I am stucked at HtmlSelectOneListbox. In my code I create one that appears on the form as well correctly, but I don't know how to add the SelectItems to it.

HtmlSelectOneListbox combo = new HtmlSelectOneListbox();
combo.setId(id);
combo.setDisabled(readOnlyWindow);

/* parent is the UIComponent instance around us*/
parent.getChildren().add(combo);

I can create instances of SelectItems or even SelectItemsTag but the combo has no methods to set them. It has only a setValue/setValueExpression and with that I could set my value binding expression to the object representing #{bean.value}. But the selectitems property should be set not on the listbox but its nested f:selectItems that I don't know how to create.


Solution

  • I think UISelectItem and/or UISelectItems objects should be added as children of HtmlSelectOneListbox in a similar way you add combo to the parent component.