diff options
-rw-r--r-- | server/src/main/java/com/vaadin/ui/ComboBox.java | 11 | ||||
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxItemIcon.java | 3 |
2 files changed, 12 insertions, 2 deletions
diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java index ef1e7cfa84..107e503256 100644 --- a/server/src/main/java/com/vaadin/ui/ComboBox.java +++ b/server/src/main/java/com/vaadin/ui/ComboBox.java @@ -842,6 +842,10 @@ public class ComboBox<T> extends AbstractSingleSelect<T> Resource icon = getItemIconGenerator().apply(value); if (icon != null) { if (icon instanceof ConnectorResource) { + if (!isAttached()) { + // Deferred resource generation. + return; + } setResource("selected", icon); } selectedItemIcon = ResourceReference @@ -852,6 +856,13 @@ public class ComboBox<T> extends AbstractSingleSelect<T> } @Override + public void attach() { + super.attach(); + + updateSelectedItemIcon(); + } + + @Override protected Element writeItem(Element design, T item, DesignContext context) { Element element = design.appendElement("option"); diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxItemIcon.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxItemIcon.java index c12ef2878f..0eb3d7c97f 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxItemIcon.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxItemIcon.java @@ -72,8 +72,7 @@ public class ComboBoxItemIcon extends TestBase { cb.setItems(IntStream.range(0, 3).boxed()); cb.setItemIconGenerator(iconGenerator); - // FIXME: Selecting ConnectorResource on init does not work. - // cb.setValue(2); + cb.setValue(1); addComponent(cb); } } |