commit 98a2455f3da2841496b415bc1f402515a6e0b034
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Thu Dec 6 16:37:42 2018 +0100

    fix #7245 fixing validation of ToOneRelatedEntityCombobox and re-enabling TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE

diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/ui/config/TaxonNamePopupEditorConfig.java b/src/main/java/eu/etaxonomy/cdm/vaadin/ui/config/TaxonNamePopupEditorConfig.java
index ca875fa0..3f3905ea 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/ui/config/TaxonNamePopupEditorConfig.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/ui/config/TaxonNamePopupEditorConfig.java
@@ -31,7 +31,7 @@ public class TaxonNamePopupEditorConfig {
         popup.enableMode(TaxonNamePopupEditorMode.AUTOFILL_AUTHORSHIP_DATA);
         popup.enableMode(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY);
         popup.enableMode(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART);
-        // popup.enableMode(TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE);
+        popup.enableMode(TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE);
     }
 
     /**
@@ -42,7 +42,7 @@ public class TaxonNamePopupEditorConfig {
     public static void configure(TaxonNamePopupEditorView popup) {
         popup.enableMode(TaxonNamePopupEditorMode.AUTOFILL_AUTHORSHIP_DATA);
         popup.enableMode(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART);
-        // popup.enableMode(TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE);
+        popup.enableMode(TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE);
     }
 
 }
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java
index de1d9a3c..f53bfc4b 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java
@@ -250,6 +250,7 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
             };
 
         }
+
         return taxonName;
     }
 
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.java
index e896c2aa..b6f65b22 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.java
@@ -320,6 +320,7 @@ public class TaxonNamePopupEditor extends AbstractCdmDTOPopupEditor<TaxonNameDTO
 
         row++;
         nomReferenceCombobox = new ToOneRelatedEntityCombobox<Reference>("Nomenclatural reference", Reference.class);
+        // nomReferenceCombobox.setImmediate(true);
         nomReferenceCombobox.addClickListenerAddEntity(e -> getViewEventBus().publish(
                 this,
                 new ReferenceEditorAction(EditorActionType.ADD, null, nomReferenceCombobox, this)
@@ -560,15 +561,16 @@ public class TaxonNamePopupEditor extends AbstractCdmDTOPopupEditor<TaxonNameDTO
         if(isModeEnabled(TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE)) {
             if(combinationAuthorshipField.getValue() == null){
                 nomReferenceCombobox.setRequired(true);
+                nomReferenceCombobox.setImmediate(true);
             } else {
                 combinationAuthorshipField.addValueChangeListener(e -> {
                     if(e.getProperty().getValue() == null){
                         nomReferenceCombobox.setRequired(true);
+                        nomReferenceCombobox.setImmediate(true);
                     }
                 });
             }
         }
-
     }
 
     /**
diff --git a/src/main/java/eu/etaxonomy/vaadin/component/ReloadableLazyComboBox.java b/src/main/java/eu/etaxonomy/vaadin/component/ReloadableLazyComboBox.java
index af14fa8b..6c1cc228 100644
--- a/src/main/java/eu/etaxonomy/vaadin/component/ReloadableLazyComboBox.java
+++ b/src/main/java/eu/etaxonomy/vaadin/component/ReloadableLazyComboBox.java
@@ -120,5 +120,4 @@ public class ReloadableLazyComboBox<T> extends LazyComboBox<T> implements Reload
         }
     }
 
-
 }
\ No newline at end of file
diff --git a/src/main/java/eu/etaxonomy/vaadin/component/ToOneRelatedEntityCombobox.java b/src/main/java/eu/etaxonomy/vaadin/component/ToOneRelatedEntityCombobox.java
index fbb6f0b2..614abee4 100644
--- a/src/main/java/eu/etaxonomy/vaadin/component/ToOneRelatedEntityCombobox.java
+++ b/src/main/java/eu/etaxonomy/vaadin/component/ToOneRelatedEntityCombobox.java
@@ -12,8 +12,13 @@ import org.vaadin.viritin.fields.LazyComboBox.FilterableCountProvider;
 import org.vaadin.viritin.fields.LazyComboBox.FilterablePagingProvider;
 
 import com.vaadin.data.Property;
+import com.vaadin.data.Validator.InvalidValueException;
 import com.vaadin.data.fieldgroup.FieldGroup;
 import com.vaadin.data.util.converter.Converter.ConversionException;
+import com.vaadin.server.AbstractErrorMessage.ContentMode;
+import com.vaadin.server.ErrorMessage;
+import com.vaadin.server.ErrorMessage.ErrorLevel;
+import com.vaadin.server.UserError;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickListener;
 import com.vaadin.ui.Component;
@@ -50,11 +55,16 @@ public class ToOneRelatedEntityCombobox<V extends Object> extends CompositeCusto
         this.type = type;
         setCaption(caption);
         lazySelect = new ReloadableLazyComboBox<V>(type);
+        lazySelect.setValidationVisible(false); // validation is to be shown for the ToOneRelatedEntityCombobox
+        lazySelect.setRequiredError("Must be given");
+        setRequiredError("Must be given");
         addStyledComponents(lazySelect, addButton, editButton);
         addSizedComponents(lazySelect, container);
+        // lazySelect.setImmediate(true); // should cause immediate validation, however,
+        // it does not work here, therefore we validate in the commitSelect() method during the commit
         lazySelect.addValueChangeListener(e -> {
             // update the itemContainer immediately so that the edit button acts on the chosen item
-            lazySelect.commit();
+            commitSelect();
         });
     }
 
@@ -169,11 +179,27 @@ public class ToOneRelatedEntityCombobox<V extends Object> extends CompositeCusto
      */
     @Override
     public V getValue() {
-        lazySelect.commit();
+        commitSelect();
         return lazySelect.getValue();
     }
 
 
+
+
+    /**
+     *
+     */
+    public void commitSelect() {
+        try {
+            setComponentError(null);
+            lazySelect.commit();
+        } catch (InvalidValueException ex){
+            UserError componentError = new UserError(ex.getHtmlMessage(), ContentMode.HTML, ErrorLevel.ERROR);
+            setComponentError(componentError);
+        }
+    }
+
+
     /**
      * {@inheritDoc}
      */
@@ -222,4 +248,57 @@ public class ToOneRelatedEntityCombobox<V extends Object> extends CompositeCusto
     }
 
 
+    @Override
+    public void validate() throws InvalidValueException {
+        super.validate();
+        lazySelect.validate();
+    }
+
+
+    @Override
+    public ErrorMessage getErrorMessage() {
+        ErrorMessage errorMessage = lazySelect.getErrorMessage();
+        return errorMessage;
+    }
+
+
+    @Override
+    public boolean isValid() {
+        return lazySelect.isValid();
+    }
+
+    @Override
+    public void setRequired(boolean required) {
+        super.setRequired(required);
+        lazySelect.setRequired(required);
+    }
+
+
+    @Override
+    public boolean isRequired() {
+        return lazySelect.isRequired();
+    }
+
+    @Override
+    public void setImmediate(boolean immediate) {
+        super.setImmediate(immediate);
+        lazySelect.setImmediate(immediate);
+    }
+
+
+    @Override
+    public void commit() throws SourceException, InvalidValueException {
+        lazySelect.commit(); // we must not use the commitSelect() here to allow InvalidValueException to be handled by the caller
+        super.commit();
+    }
+
+
+    @Override
+    public void setComponentError(ErrorMessage componentError) {
+        lazySelect.setComponentError(componentError);
+        super.setComponentError(componentError);
+    }
+
+
+
 }
diff --git a/src/main/webapp/VAADIN/themes/edit-valo/custom-fields.scss b/src/main/webapp/VAADIN/themes/edit-valo/custom-fields.scss
index 1d94c78c..fd9ed6da 100644
--- a/src/main/webapp/VAADIN/themes/edit-valo/custom-fields.scss
+++ b/src/main/webapp/VAADIN/themes/edit-valo/custom-fields.scss
@@ -164,6 +164,16 @@ body .edit-valo { // increasing specifity to allow overriding the valo default f
         .v-filterselect-button {
             right: $v-unit-size * 2 + 1px;
         }
+        .v-component-group {
+          .v-required-field-indicator {
+              // no not show the indicator of the nested select
+              display: none;
+          }
+          .v-errorindicator {
+             // no not show the indicator of the nested select
+              display: none;
+          }
+        }
     }
     
     // ------------ minMaxTextField ------------ //
