@@ -548,6 +572,32 @@ public void footerCloseAction() {
getElement().executeJs("$0.__close()", getElement());
}
+ /**
+ * Copy the selected value of the field into the grid
+ */
+ @ClientCallable
+ private void openErrorNotification() {
+ getNotificationWhenEmptySelection().run();
+ }
+
+ private Runnable getNotificationWhenEmptySelection() {
+ if (notificationWhenEmptySelection == null) {
+ return () -> {
+ String emptySelection = (getI18n() == null)? "Please select an item.":getI18n().getEmptyselection();
+ new Notification(emptySelection, 2000, Notification.Position.TOP_CENTER).open();
+ };
+ }
+ return notificationWhenEmptySelection;
+ }
+
+ /**
+ * Replace the default notification to an action
+ *
+ * @param notificationWhenEmptySelection action to run when the selection is empty and the select button is clicked
+ */
+ public void addEmptySelectionListener(Runnable notificationWhenEmptySelection) {
+ this.notificationWhenEmptySelection = notificationWhenEmptySelection;
+ }
/**
* The internationalization properties for {@link LookupField}.
@@ -559,6 +609,7 @@ public static class LookupFieldI18n implements Serializable {
private String headerprefix;
private String headerpostfix;
private String search;
+ private String emptyselection;
public String getSearch() {
return search;
@@ -613,5 +664,14 @@ public LookupFieldI18n setHeaderpostfix(String headerpostfix) {
this.headerpostfix = headerpostfix;
return this;
}
+
+ public String getEmptyselection() {
+ return emptyselection;
+ }
+
+ public LookupFieldI18n setEmptyselection(String emptyselection) {
+ this.emptyselection = emptyselection;
+ return this;
+ }
}
}
diff --git a/pom.xml b/pom.xml
index f89e176..ecb3284 100755
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@