public void setModel(BeanItemContainer<T> model) { AbstractSelect presentation = getPresentation(); if (presentation != null) { presentation.setContainerDataSource(model); } this.model = model; }
@SuppressWarnings("unchecked") public T[] getSelection() { AbstractSelect presentation = getPresentation(); if (presentation != null) { Object value = presentation.getValue(); if (value instanceof Collection<?>) { Collection<T> collection = (Collection<T>) value; selection = collection.toArray((T[]) Array.newInstance(beanType, collection.size())); } else { selection = (T[]) Array.newInstance(beanType, 1); selection[0] = (T) value; } } return selection; }
@SafeVarargs public final void setSelection(T... selection) { AbstractSelect presentation = getPresentation(); if (presentation != null) { switch (selection.length) { case 0: presentation.setValue(null); break; case 1: presentation.setValue(selection[0]); break; default: presentation.setValue(Arrays.asList(selection)); } } this.selection = selection; }