You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2019/11/28 12:47:00 UTC

[empire-db] branch master updated: EMPIREDB-320 skipping validation of child input components for e:input and e:control tags

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 f6d7b8b  EMPIREDB-320 skipping validation of child input components for e:input and e:control tags
f6d7b8b is described below

commit f6d7b8be5435c70b51fd7feb5f8d171dc6a1a389
Author: Rainer Döbele <do...@apache.org>
AuthorDate: Thu Nov 28 13:46:56 2019 +0100

    EMPIREDB-320
    skipping validation of child input components for e:input and e:control tags
---
 .../apache/empire/jsf2/components/ControlTag.java  | 75 ++++++++++++++--------
 .../apache/empire/jsf2/components/InputTag.java    | 70 +++++++++++++-------
 .../empire/jsf2/controls/SelectInputControl.java   |  8 +++
 3 files changed, 106 insertions(+), 47 deletions(-)

diff --git a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ControlTag.java b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ControlTag.java
index 58396d1..7356389 100644
--- a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ControlTag.java
+++ b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ControlTag.java
@@ -218,17 +218,18 @@ public class ControlTag extends UIInput implements NamingContainer
     }
 
     // Logger
-    private static final Logger       log                = LoggerFactory.getLogger(ControlTag.class);
+    private static final Logger       log                  = LoggerFactory.getLogger(ControlTag.class);
 
-    protected static final String     readOnlyState      = "readOnlyState";
+    protected static final String     readOnlyState        = "readOnlyState";
 
-    protected final TagEncodingHelper helper             = TagEncodingHelperFactory.create(this, "eInput");
+    protected final TagEncodingHelper helper               = TagEncodingHelperFactory.create(this, "eInput");
 
-    protected InputControl            control            = null;
-    protected InputControl.InputInfo  inpInfo            = null;
-    protected boolean                 hasRequiredFlagSet = false;
-    protected boolean                 encodeLabel        = true;
-    private   boolean                 creatingComponents = false;
+    protected InputControl            control              = null;
+    protected InputControl.InputInfo  inpInfo              = null;
+    protected boolean                 hasRequiredFlagSet   = false;
+    protected boolean                 encodeLabel          = true;
+    private boolean                   creatingComponents   = false;
+    protected boolean                 processingValidators = false;
 
     public ControlTag()
     {
@@ -417,8 +418,7 @@ public class ControlTag extends UIInput implements NamingContainer
                 {   // set rendered 
                     boolean rendered = (child instanceof ValueOutputComponent) ? readOnly : !readOnly;
                     if (child.isRendered()!=rendered)
-                    {
-                        child.setRendered(rendered);
+                    {   child.setRendered(rendered);
                         hasChanged = true;
                     }    
                 }
@@ -578,28 +578,35 @@ public class ControlTag extends UIInput implements NamingContainer
         ControlSeparatorComponent inputSepTag = (ControlSeparatorComponent) getChildren().get(1);
         return this.control.getConvertedValue(inputSepTag, this.inpInfo, newSubmittedValue);
     }
+    
+    @Override
+    public int getChildCount()
+    {
+        return (processingValidators ? 0 : super.getChildCount());
+    }
+    
+    @Override
+    public int getFacetCount()
+    {
+        return (processingValidators ? 0 : super.getFacetCount());
+    }
 
     @Override
-    public void validateValue(FacesContext context, Object value)
-    { // Check state
-        if (this.inpInfo == null || !isValid())
-            return;
-        // Skip Null values on partial submit
-        if (UIInput.isEmpty(value) && isPartialSubmit(context)) //  && helper.isValueRequired()
-        { // Value is null
-            log.debug("Skipping validation for {} due to Null value.", this.inpInfo.getColumn().getName());
-            return;
+    public void processValidators(FacesContext context)
+    {
+        try {
+            processingValidators = true;
+            super.processValidators(context);
+        } finally {
+            processingValidators = false;
         }
-        // Validate value
-        this.inpInfo.validate(value);
-        setValid(true);
-        // don't call base class!
-        // super.validateValue(context, value);
     }
 
     @Override
     public void validate(FacesContext context)
-    {
+    {   // free Validators lock
+        processingValidators = false;
+        // init state
         if (initState(context) == false)
             return;
         // get submitted value and validate
@@ -621,6 +628,24 @@ public class ControlTag extends UIInput implements NamingContainer
     }
 
     @Override
+    public void validateValue(FacesContext context, Object value)
+    { // Check state
+        if (this.inpInfo == null || !isValid())
+            return;
+        // Skip Null values on partial submit
+        if (UIInput.isEmpty(value) && isPartialSubmit(context)) //  && helper.isValueRequired()
+        { // Value is null
+            log.debug("Skipping validation for {} due to Null value.", this.inpInfo.getColumn().getName());
+            return;
+        }
+        // Validate value
+        this.inpInfo.validate(value);
+        setValid(true);
+        // don't call base class!
+        // super.validateValue(context, value);
+    }
+
+    @Override
     public void updateModel(FacesContext context)
     {
         if (initState(context) == false)
diff --git a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/InputTag.java b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/InputTag.java
index cec5a1f..ae6a209 100644
--- a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/InputTag.java
+++ b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/InputTag.java
@@ -44,17 +44,18 @@ import org.slf4j.LoggerFactory;
 public class InputTag extends UIInput implements NamingContainer
 {
     // Logger
-    private static final Logger       log                = LoggerFactory.getLogger(InputTag.class);
+    private static final Logger       log                  = LoggerFactory.getLogger(InputTag.class);
 
     // private static final String inpControlPropName = InputControl.class.getSimpleName();
     // private static final String inputInfoPropName = InputControl.InputInfo.class.getSimpleName();
-    protected static final String     readOnlyState      = "readOnlyState";
+    protected static final String     readOnlyState        = "readOnlyState";
 
-    protected final TagEncodingHelper helper             = TagEncodingHelperFactory.create(this, "eInput");
+    protected final TagEncodingHelper helper               = TagEncodingHelperFactory.create(this, "eInput");
 
-    protected InputControl            control            = null;
-    protected InputControl.InputInfo  inpInfo            = null;
-    protected boolean                 hasRequiredFlagSet = false;
+    protected InputControl            control              = null;
+    protected InputControl.InputInfo  inpInfo              = null;
+    protected boolean                 hasRequiredFlagSet   = false;
+    protected boolean                 processingValidators = false;
 
     /*
     private static int itemIdSeq = 0;
@@ -220,7 +221,7 @@ public class InputTag extends UIInput implements NamingContainer
         // done
         return compId;
     }
-
+    
     @Override
     public void processDecodes(FacesContext context) 
     {
@@ -281,28 +282,35 @@ public class InputTag extends UIInput implements NamingContainer
         // parse and convert value
         return this.control.getConvertedValue(this, this.inpInfo, newSubmittedValue);
     }
+    
+    @Override
+    public int getChildCount()
+    {
+        return (processingValidators ? 0 : super.getChildCount());
+    }
+    
+    @Override
+    public int getFacetCount()
+    {
+        return (processingValidators ? 0 : super.getFacetCount());
+    }
 
     @Override
-    public void validateValue(FacesContext context, Object value)
-    { // Check state
-        if (inpInfo == null)
-            return;
-        // Skip Null values if not required
-        if (UIInput.isEmpty(value) && isPartialSubmit(context)) //  && helper.isValueRequired()
-        { // Value is null
-            log.debug("Skipping validation for {} due to Null value.", inpInfo.getColumn().getName());
-            return;
+    public void processValidators(FacesContext context)
+    {
+        try {
+            processingValidators = true;
+            super.processValidators(context);
+        } finally {
+            processingValidators = false;
         }
-        // Validate value
-        inpInfo.validate(value);
-        setValid(true);
-        // don't call base class!
-        // super.validateValue(context, value);
     }
 
     @Override
     public void validate(FacesContext context)
-    {
+    {   // free Validators lock
+        processingValidators = false;
+        // init state
         if (initState(context) == false)
             return;
         // get submitted value and validate
@@ -323,6 +331,24 @@ public class InputTag extends UIInput implements NamingContainer
             setValid(false);
         }
     }
+    
+    @Override
+    public void validateValue(FacesContext context, Object value)
+    {   // Check state
+        if (inpInfo == null)
+            return;
+        // Skip Null values if not required
+        if (UIInput.isEmpty(value) && isPartialSubmit(context)) //  && helper.isValueRequired()
+        { // Value is null
+            log.debug("Skipping validation for {} due to Null value.", inpInfo.getColumn().getName());
+            return;
+        }
+        // Validate value
+        inpInfo.validate(value);
+        setValid(true);
+        // don't call base class!
+        // super.validateValue(context, value);
+    }
 
     @Override
     public void updateModel(FacesContext context)
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 0d2c649..b973291 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
@@ -211,6 +211,14 @@ public class SelectInputControl extends InputControl
             {   emptyPresent = true;
                 continue;
             }
+            // skip inactive
+            while (oe!=null && !oe.isActive())
+            {   // check for current
+                if (ObjectUtils.compareEqual(oe.getValue(), currentValue))
+                    break;
+                // next oe
+                oe = ioe.next();
+            }
             if (oe == null)
             {   // remove obsolete items
                 lastIndex--;