This is an automated email from the ASF dual-hosted git repository.

doebele pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/empire-db.git


The following commit(s) were added to refs/heads/master by this push:
     new 88f451c  EMPIREDB-282 optimization
88f451c is described below

commit 88f451cea3f8034e6f304adbd7d66efe3035c96a
Author: Rainer Döbele <[email protected]>
AuthorDate: Wed Oct 2 19:16:38 2019 +0200

    EMPIREDB-282
    optimization
---
 .../org/apache/empire/jsf2/controls/SelectInputControl.java    | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java
 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java
index e6222ce..b60b8d0 100644
--- 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java
+++ 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java
@@ -87,7 +87,7 @@ public class SelectInputControl extends InputControl
         input.setDisabled(disabled);
         // Options
         Options options = getOptions(ii);
-        boolean addEmpty = getEmptyEntryRequired(ii, disabled) && 
!options.contains("");
+        boolean addEmpty = isEmptyEntryRequired(options, ii, disabled);
         String nullText = (addEmpty) ? getNullText(ii) : "";
         initOptions(input, ii.getTextResolver(), options, addEmpty, nullText);
         // add
@@ -117,7 +117,7 @@ public class SelectInputControl extends InputControl
         Options options = ii.getOptions();
         if (options!=null)
         {   // syncOptions
-            boolean addEmpty = getEmptyEntryRequired(ii, disabled) && 
!options.contains("");
+            boolean addEmpty = isEmptyEntryRequired(options, ii, disabled);
             String nullText = (addEmpty) ? getNullText(ii) : "";
             syncOptions(input, ii.getTextResolver(), options, addEmpty, 
nullText, ii.isInsideUIData());
         }
@@ -138,8 +138,12 @@ public class SelectInputControl extends InputControl
         }
     }
 
-    protected boolean getEmptyEntryRequired(InputInfo ii, boolean disabled)
+    protected boolean isEmptyEntryRequired(Options options, InputInfo ii, 
boolean disabled)
     {
+        if (options.contains(""))
+        {   // already has an empty option
+            return false;
+        }
         if (!ii.isRequired() && !(disabled && ii.getColumn().isRequired()))
         {
             return true;

Reply via email to