Reputation: 2400
I have an object of SelectManyCheckbox. For this object I set available values in the next way:
SelectManyCheckbox checkbox = new SelectManyCheckbox();
List<Double> selected = new ArrayList<Double>();//this will be used for setting selected values
List<SelectItem> items = new ArrayList<SelectItem>();//this will be used as available values
for (SomeObject av : listOfObjects)
{
SelectItem item = new SelectItem(av.getNumericValue(),
av.getValue());
items.add(item);
if (av.getDefault())
{
selected.add(av.getNumericValue());
}
}
UISelectItems uiItems = new UISelectItems();
uiItems.setValue(items);
checkbox.getChildren().add(uiItems);
checkbox.setSelectedValues(new Double[selected.size()]);
But this way of setting of selected values does not work. Maybe someone know there is the source of the problem?
Upvotes: 1
Views: 527
Reputation: 1113
Your Double[] is empty there, try converting the list to the array like this:
checkbox.setSelectedValues(selected.toArray(new Double[selected.size()]));
Upvotes: 1