aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorDenis Anisimov <denis@vaadin.com>2016-11-29 15:27:20 +0300
committerVaadin Code Review <review@vaadin.com>2016-12-01 07:42:43 +0000
commit1bb04399f3b825203a2c6d62154750768d75003e (patch)
treef90007d4358de336e05fcadd5d2f99c0999d6e19 /server
parente4fbf7a5f2ab83d613100ec83aac99a3f88bf8b9 (diff)
downloadvaadin-framework-1bb04399f3b825203a2c6d62154750768d75003e.tar.gz
vaadin-framework-1bb04399f3b825203a2c6d62154750768d75003e.zip
Allow to set caption for the empty selection in a ComboBox.
Fixes vaadin/framework8-issues#163 Change-Id: Ib68ad5421934c8375a91d7948d860381a5adb9bb
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/ui/ComboBox.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java
index 9034fabf11..093c5e9c7a 100644
--- a/server/src/main/java/com/vaadin/ui/ComboBox.java
+++ b/server/src/main/java/com/vaadin/ui/ComboBox.java
@@ -402,6 +402,43 @@ public class ComboBox<T> extends AbstractSingleSelect<T>
}
/**
+ * Returns the empty selection caption.
+ * <p>
+ * The empty string {@code ""} is the default empty selection caption.
+ *
+ * @see #setEmptySelectionAllowed(boolean)
+ * @see #isEmptySelectionAllowed()
+ * @see #setEmptySelectionCaption(String)
+ * @see #isSelected(Object)
+ * @see #select(Object)
+ *
+ * @return the empty selection caption, not {@code null}
+ */
+ public String getEmptySelectionCaption() {
+ return getState(false).emptySelectionCaption;
+ }
+
+ /**
+ * Sets the empty selection caption.
+ * <p>
+ * The empty string {@code ""} is the default empty selection caption.
+ * <p>
+ * If empty selection is allowed via the
+ * {@link #setEmptySelectionAllowed(boolean)} method (it is by default) then
+ * the empty item will be shown with the given caption.
+ *
+ * @param caption
+ * the caption to set, not {@code null}
+ * @see #getNullSelectionItemId()
+ * @see #isSelected(Object)
+ * @see #select(Object)
+ */
+ public void setEmptySelectionCaption(String caption) {
+ Objects.nonNull(caption);
+ getState().emptySelectionCaption = caption;
+ }
+
+ /**
* Sets the suggestion pop-up's width as a CSS string. By using relative
* units (e.g. "50%") it's possible to set the popup's width relative to the
* ComboBox itself.