aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/ui/AbstractSelect.java
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2007-11-02 08:45:43 +0000
committerMarc Englund <marc.englund@itmill.com>2007-11-02 08:45:43 +0000
commit351c76dd06dbf2060f4492042e4b66e1b45f89dd (patch)
tree8a8fc288cd769f74f27f5367912d0b998306793a /src/com/itmill/toolkit/ui/AbstractSelect.java
parentda6001c7b1bf6839c266052f7995ad90db3850d3 (diff)
downloadvaadin-framework-351c76dd06dbf2060f4492042e4b66e1b45f89dd.tar.gz
vaadin-framework-351c76dd06dbf2060f4492042e4b66e1b45f89dd.zip
Don't paint the null selection item if nullselection is not allowed.
svn changeset:2670/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/ui/AbstractSelect.java')
-rw-r--r--src/com/itmill/toolkit/ui/AbstractSelect.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/com/itmill/toolkit/ui/AbstractSelect.java b/src/com/itmill/toolkit/ui/AbstractSelect.java
index f86bd94c52..939cdd248d 100644
--- a/src/com/itmill/toolkit/ui/AbstractSelect.java
+++ b/src/com/itmill/toolkit/ui/AbstractSelect.java
@@ -297,8 +297,8 @@ public abstract class AbstractSelect extends AbstractField implements
int keyIndex = 0;
// Support for external null selection item id
Collection ids = getItemIds();
- if (getNullSelectionItemId() != null
- && (!ids.contains(getNullSelectionItemId()))) {
+ if (isNullSelectionAllowed() && getNullSelectionItemId() != null
+ && !ids.contains(getNullSelectionItemId())) {
// Gets the option attribute values
Object id = getNullSelectionItemId();
String key = this.itemIdMapper.key(id);
@@ -324,6 +324,12 @@ public abstract class AbstractSelect extends AbstractField implements
while (i.hasNext()) {
// Gets the option attribute values
Object id = i.next();
+ if (!isNullSelectionAllowed() && id != null
+ && id.equals(getNullSelectionItemId())) {
+ // Remove item if it's the null selection item but null
+ // selection is not allowed
+ continue;
+ }
String key = this.itemIdMapper.key(id);
String caption = getItemCaption(id);
Resource icon = getItemIcon(id); // Paints the option
@@ -862,7 +868,8 @@ public abstract class AbstractSelect extends AbstractField implements
*/
public void setMultiSelect(boolean multiSelect) {
if (multiSelect && getNullSelectionItemId() != null) {
- throw new IllegalStateException();
+ throw new IllegalStateException(
+ "Multiselect and NullSelectionItemId can not be set at the same time.");
}
if (multiSelect != this.multiSelect) {
@@ -1496,7 +1503,8 @@ public abstract class AbstractSelect extends AbstractField implements
*/
public void setNullSelectionItemId(Object nullSelectionItemId) {
if (nullSelectionItemId != null && isMultiSelect()) {
- throw new IllegalStateException();
+ throw new IllegalStateException(
+ "Multiselect and NullSelectionItemId can not be set at the same time.");
}
this.nullSelectionItemId = nullSelectionItemId;
}