diff options
Diffstat (limited to 'server/src/com/vaadin/ui/AbstractSelect.java')
-rw-r--r-- | server/src/com/vaadin/ui/AbstractSelect.java | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java index 2c4dd5be5d..1a3eeb88a3 100644 --- a/server/src/com/vaadin/ui/AbstractSelect.java +++ b/server/src/com/vaadin/ui/AbstractSelect.java @@ -33,6 +33,8 @@ import com.vaadin.data.Container; import com.vaadin.data.Item; import com.vaadin.data.Property; import com.vaadin.data.util.IndexedContainer; +import com.vaadin.data.util.converter.Converter; +import com.vaadin.data.util.converter.ConverterUtil; import com.vaadin.event.DataBoundTransferable; import com.vaadin.event.Transferable; import com.vaadin.event.dd.DragAndDropEvent; @@ -1181,7 +1183,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements switch (getItemCaptionMode()) { case ID: - caption = itemId.toString(); + caption = idToCaption(itemId); break; case INDEX: @@ -1207,7 +1209,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements case EXPLICIT_DEFAULTS_ID: caption = itemCaptions.get(itemId); if (caption == null) { - caption = itemId.toString(); + caption = idToCaption(itemId); } break; @@ -1227,6 +1229,17 @@ public abstract class AbstractSelect extends AbstractField<Object> implements return caption != null ? caption : ""; } + private String idToCaption(Object itemId) { + try { + Converter<String, Object> c = (Converter<String, Object>) ConverterUtil + .getConverter(String.class, itemId.getClass(), getSession()); + return ConverterUtil.convertFromModel(itemId, String.class, c, + getLocale()); + } catch (Exception e) { + return itemId.toString(); + } + } + /** * Sets tqhe icon for an item. * @@ -1782,7 +1795,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * @see AbstractField#isEmpty(). */ @Override - protected boolean isEmpty() { + public boolean isEmpty() { if (!multiSelect) { return super.isEmpty(); } else { |