LinkedList s = new LinkedList();
for (int i = 0; i < ka.length; i++) {
Object id = this.itemIdMapper.get(ka[i]);
- if (id != null && containsId(id)) {
+ if (!isNullSelectionAllowed()
+ && (id == null || id == getNullSelectionItemId())) {
+ // skip empty selection if nullselection is not allowed
+ requestRepaint();
+ } else if (id != null && containsId(id)) {
s.add(id);
} else if (this.itemIdMapper.isNewIdKey(ka[i])
&& newitem != null && newitem.length() > 0) {
}
}
+ if (!isNullSelectionAllowed() && s.size() < 1) {
+ // empty selection not allowed, keep old value
+ requestRepaint();
+ return;
+ }
+
// Limits the deselection to the set of visible items
// (non-visible items can not be deselected)
Collection visible = getVisibleItemIds();
}
} else {
// Single select mode
+ if (!isNullSelectionAllowed()
+ && (ka.length == 0 || ka[0] == null || ka[0] == getNullSelectionItemId())) {
+ requestRepaint();
+ return;
+ }
if (ka.length == 0) {
- // Allows deselection only if the deselected item is visible
+ // Allows deselection only if the deselected item is
+ // visible
Object current = getValue();
Collection visible = getVisibleItemIds();
if (visible != null && visible.contains(current)) {
}
} else {
Object id = this.itemIdMapper.get(ka[0]);
- if (id != null && id.equals(getNullSelectionItemId())) {
+ if (!isNullSelectionAllowed() && id == null) {
+ requestRepaint();
+ } else if (id != null
+ && id.equals(getNullSelectionItemId())) {
setValue(null, true);
} else if (this.itemIdMapper.isNewIdKey(ka[0])) {
setValue(newitem);
*/
public void changeVariables(Object source, Map variables) {
+ if (!isSelectable() && variables.containsKey("selected")) {
+ // Not-selectable is a special case, AbstractSelect does not support
+ // TODO could be optimized.
+ variables = new HashMap(variables);
+ variables.remove("selected");
+ }
+
super.changeVariables(source, variables);
// Page start index
}
target.startTag("rows");
for (int i = 0; i < cells[0].length; i++) {
- target.startTag("tr");
Object itemId = cells[CELL_ITEMID][i];
+ if (!isNullSelectionAllowed() && getNullSelectionItemId() != null
+ && itemId == getNullSelectionItemId()) {
+ // Remove null selection item if null selection is not allowed
+ continue;
+ }
+
+ target.startTag("tr");
+
// tr attributes
if (rowheads) {
if (cells[CELL_ICON][i] != null) {
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
*/
public void changeVariables(Object source, Map variables) {
+ if (!isSelectable() && variables.containsKey("selected")) {
+ // Not-selectable is a special case, AbstractSelect does not support
+ // TODO could be optimized.
+ variables = new HashMap(variables);
+ variables.remove("selected");
+ }
+
// Collapses the nodes
if (variables.containsKey("collapse")) {
String[] keys = (String[]) variables.get("collapse");