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/05 14:15:19 UTC

[empire-db] branch master updated: EMPIREDB-317 reset record inside UIData

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 d13a0cd  EMPIREDB-317 reset record inside UIData
d13a0cd is described below

commit d13a0cd2e1149a4ec095d53770d439e6f6f5a2a5
Author: Rainer Döbele <do...@apache.org>
AuthorDate: Tue Nov 5 15:15:14 2019 +0100

    EMPIREDB-317
    reset record inside UIData
---
 .../org/apache/empire/jsf2/app/WebApplication.java |  7 ++--
 .../apache/empire/jsf2/components/ControlTag.java  |  2 --
 .../apache/empire/jsf2/components/InputTag.java    | 41 +++++++++-------------
 .../org/apache/empire/jsf2/components/LinkTag.java |  2 --
 .../empire/jsf2/utils/TagEncodingHelper.java       | 19 +++++++---
 5 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/WebApplication.java b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/WebApplication.java
index bafac8f..682298d 100644
--- a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/WebApplication.java
+++ b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/WebApplication.java
@@ -98,8 +98,11 @@ public abstract class WebApplication
     public final void init(FacesImplementation facesImpl, FacesContext startupContext)
     {
         // Only call once!
-        if (this.facesImpl!=null || this.webRoot!=null)
-            throw new NotSupportedException(this, "init");
+        if (this.facesImpl!=null || this.webRoot!=null) 
+        {   // already initialized
+            log.warn("WARNING: WebApplication has already been initialized! Continuing without init...");
+            return;
+        }
         // set imppl
         this.facesImpl = facesImpl;
         // webRoot
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 bff104f..eaef04b 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
@@ -390,8 +390,6 @@ public class ControlTag extends UIInput implements NamingContainer
         id = helper.completeInputTagId(id); 
         // set
         super.setId(id);
-        // reset record
-        helper.setRecord(null);
     }
 
     @Override
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 59fa69e..2e6fe6a 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
@@ -139,7 +139,11 @@ public class InputTag extends UIInput implements NamingContainer
         // add label and input components when the view is loaded for the first time
         super.encodeBegin(context);
 
-        // Check visiblity
+        // get Control (before checking visible)
+        helper.encodeBegin();
+        this.control = helper.getInputControl();
+        
+        // Check visibility
         if (helper.isVisible() == false)
         {   // not visible
             setRendered(false);
@@ -149,31 +153,22 @@ public class InputTag extends UIInput implements NamingContainer
                 throw new InvalidArgumentException("column", null);
             // Check record
             Object record = helper.getRecord();
-            if (record!=null && (record instanceof DBRecord))
-            {   // Record is not null
-                if (((DBRecord)record).isValid())
-                {   // Check if column exists
-                    if (((DBRecord)record).getFieldIndex(column)<0)
-                        throw new InvalidArgumentException("column", column.getName());
-                    // not visible
-                    log.info("Column {} is not visible for record of {} and will not be rendered!", column.getName(), ((DBRecord)record).getRowSet().getName());
-                }    
-                else
-                {   // Record not valid
-                    log.warn("Invalid Record provided for column {}. Input will not be rendered!", column.getName());
-                }    
-            }
+            if (record!=null && (record instanceof DBRecord) && ((DBRecord)record).isValid())
+            {   // Check if column exists
+                if (((DBRecord)record).getFieldIndex(column)<0)
+                    throw new InvalidArgumentException("column", column.getName());
+                // not visible
+                log.info("Column {} is not visible for record of {} and will not be rendered!", column.getName(), ((DBRecord)record).getRowSet().getName());
+            }    
             else
-            {   // Column not visible
-                log.warn("Column {} is not visible will not be rendered!", column.getName());
-            }
+            {   // Record not valid
+                log.warn("Invalid Record provided for column {}. Input will not be rendered!", column.getName());
+            }    
             return; // not visible
         }
 
-        // init
-        helper.encodeBegin();
-        control = helper.getInputControl();
-        inpInfo = helper.getInputInfo(context);
+        // render
+        this.inpInfo = helper.getInputInfo(context);
         // set required
         if (hasRequiredFlagSet == false)
             super.setRequired(helper.isValueRequired());
@@ -213,8 +208,6 @@ public class InputTag extends UIInput implements NamingContainer
         id = helper.completeInputTagId(id); 
         // setId
         super.setId(id);
-        // reset record
-        helper.setRecord(null);
     }
 
     @Override
diff --git a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/LinkTag.java b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/LinkTag.java
index eb3a0ad..a14732c 100644
--- a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/LinkTag.java
+++ b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/LinkTag.java
@@ -99,8 +99,6 @@ public class LinkTag extends UIOutput // implements NamingContainer
         }
         // set
         super.setId(id);
-        // reset record
-        helper.setRecord(null);
     }
     
     @Override
diff --git a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
index 45c8724..0459c47 100644
--- a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
+++ b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
@@ -427,6 +427,7 @@ public class TagEncodingHelper implements NamingContainer
             {   /* clear local value */
                 if (log.isDebugEnabled())
                     log.debug("clearing local value for {}. value is {}.", getColumnName(), ((UIInput)component).getLocalValue());
+                // reset
                 ((UIInput)component).setValue(null);
                 ((UIInput)component).setLocalValueSet(false);
             }
@@ -569,10 +570,12 @@ public class TagEncodingHelper implements NamingContainer
                 {   // Record has changed
                     setRecord(rec);
                 }
-            }    
-            // Invalidate if not an instance of Record
-            else if (!(this.record instanceof Record))
-                this.record = null;
+            }  
+            // Invalidate if inside UIData
+            else if (isInsideUIData())
+            {   // reset record
+                setRecord(null);
+            }
         }
     }
 
@@ -657,7 +660,12 @@ public class TagEncodingHelper implements NamingContainer
         if (this.recordTag != null)
             return this.recordTag.getRecord();
         if (this.uiDataTag != null)
-            return this.uiDataTag.getRowData();
+        {   // check row available
+            if (this.uiDataTag.isRowAvailable())
+                return this.uiDataTag.getRowData();
+            // row not available (possibly deleted)
+            return null;
+        }
         // walk upwards the parent component tree and return the first record component found (if any)
         UIComponent parent = component;
         while ((parent = parent.getParent()) != null)
@@ -670,6 +678,7 @@ public class TagEncodingHelper implements NamingContainer
             if (parent instanceof UIData)
             {
                 this.uiDataTag = (UIData)parent;
+                this.insideUIData = true;
                 return this.uiDataTag.getRowData();
             }
         }