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 2021/04/28 14:36:08 UTC

[empire-db] branch master updated: EMPIREDB-348 render Value when field is readonly, but allow override with value "never"

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 80785bc  EMPIREDB-348 render Value when field is readonly, but allow override with value "never"
80785bc is described below

commit 80785bcd243a0c7aaae76fd865a8ede4ecd481ab
Author: Rainer Döbele <do...@apache.org>
AuthorDate: Wed Apr 28 16:36:03 2021 +0200

    EMPIREDB-348
    render Value when field is readonly, but allow override with value "never"
---
 .../empire/jsf2/controls/SelectInputControl.java   |  2 +-
 .../empire/jsf2/utils/TagEncodingHelper.java       | 45 ++++++++++------------
 2 files changed, 21 insertions(+), 26 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 cdfbecd..9f39584 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
@@ -82,7 +82,7 @@ public class SelectInputControl extends InputControl
         // copy Attributes
         copyAttributes(parent, ii, input);
         // disabled
-        boolean disabled = ii.isDisabled();
+        boolean disabled = ii.isDisabled() || ii.isFieldReadOnly();
         input.setDisabled(disabled);
         // Options
         initOptions(input, ii.getTextResolver(), ii);
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 75a683c..8fea07a 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
@@ -351,24 +351,11 @@ public class TagEncodingHelper implements NamingContainer
 
         @Override
         public boolean isFieldReadOnly()
-        {   // Check Record
-            if (isRecordReadOnly())
-                return true;
-            // Check tag
+        {   // Check tag
             if (!(component instanceof UIInput))
                 return true;
-            // Check Record
-            if ((getRecord() instanceof Record))
-            { // Ask Record
-                Record r = (Record) record;
-                return r.isFieldReadOnly(getColumn());
-            }
-            // override 
-            Object val = getTagAttributeValue("readonly");
-            if (val!=null)
-                return ObjectUtils.getBoolean(val);
-            // column
-            return getColumn().isReadOnly();
+            // column read only
+            return TagEncodingHelper.this.isReadOnly();
         }
         
         @Override
@@ -812,28 +799,36 @@ public class TagEncodingHelper implements NamingContainer
 
     public boolean isRenderValueComponent()
     {
-        return isRecordReadOnly();
+        return isReadOnly();
     }
     
     public boolean isRecordReadOnly()
     {
-        // check attribute
-        Object val = getTagAttributeValue("readonly");
-        if (val != null && ObjectUtils.getBoolean(val))
-            return true;
         // Do we have a record?
         if (getRecord() instanceof RecordData)
-        { // Only a RecordData?
-            if (!(record instanceof Record) || ((Record) record).isReadOnly())
+        {   // Only a RecordData?
+            if (!(record instanceof Record))
                 return true;
         }
         else if (!hasValueExpression())
-        { // No Value expression given
+        {   // No Value expression given
             return true;
         }
-        // Check Component
+        // check attribute
+        Object val = getTagAttributeValue("readonly");
+        if (val != null)
+        {   // check
+            if (StringUtils.valueOf(val).equalsIgnoreCase("never"))
+                return false;
+            if (ObjectUtils.getBoolean(val))
+                return true;
+        }
+        // check record component
         if (recordTag != null && recordTag.isReadOnly())
             return true;
+        // Do we have a record?
+        if ((record instanceof Record) && ((Record)record).isReadOnly())
+            return true;
         // column
         return false;
     }