/** * Sets the visible value of the property. * * <p> * The value of the select is the selected item id. If the select is in * multiselect-mode, the value is a set of selected item keys. In * multiselect mode all collections of id:s can be assigned. * </p> * * @param newValue * the New selected item or collection of selected items. * @see AbstractField#setValue(java.lang.Object) */ @Override public void setValue(Object newValue) throws Property.ReadOnlyException { if (newValue == getNullSelectionItemId()) { newValue = null; } setValue(newValue, false); }
/** * Tests if an item is selected. * * <p> * In single select mode testing selection status of the item identified by * {@link #getNullSelectionItemId()} returns true if the value of the * property is null. * </p> * * @param itemId * the Id the of the item to be tested. * @see #getNullSelectionItemId() * @see #setNullSelectionItemId(Object) * */ public boolean isSelected(Object itemId) { if (itemId == null) { return false; } if (isMultiSelect()) { return ((Set<?>) getValue()).contains(itemId); } else { final Object value = getValue(); return itemId .equals(value == null ? getNullSelectionItemId() : value); } }
if (multiSelect && getNullSelectionItemId() != null) { throw new IllegalStateException( "Multiselect and NullSelectionItemId can not be set at the same time.");
final Object id = itemIdMapper.get(key); if (!isNullSelectionAllowed() && (id == null || id == getNullSelectionItemId())) { && (clientSideSelectedKeys.length == 0 || clientSideSelectedKeys[0] == null || clientSideSelectedKeys[0] == getNullSelectionItemId())) { markAsDirty(); return; markAsDirty(); } else if (id != null && id.equals(getNullSelectionItemId())) { setValue(null, true); } else {
protected void paintItem(PaintTarget target, Object itemId) throws PaintException { final String key = itemIdMapper.key(itemId); final String caption = getItemCaption(itemId); final Resource icon = getItemIcon(itemId); if (icon != null) { target.addAttribute("icon", icon); } target.addAttribute("caption", caption); if (itemId != null && itemId.equals(getNullSelectionItemId())) { target.addAttribute("nullselection", true); } target.addAttribute("key", key); if (isSelected(itemId)) { target.addAttribute("selected", true); } }
if (getNullSelectionItemId() != null) { target.addAttribute("nullselectitem", true); } else { selectedKeys = new String[(getValue() == null && getNullSelectionItemId() == null ? 0 : 1)]; if (isNullSelectionAllowed() && getNullSelectionItemId() != null && !ids.contains(getNullSelectionItemId())) { final Object id = getNullSelectionItemId(); && id.equals(getNullSelectionItemId())) {