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 36fa1dc  EMPIREDB-307 Make TagEncodingHelper overridable
36fa1dc is described below

commit 36fa1dc45056129c657d0dab882dc9dfd822dd0a
Author: Rainer Döbele <[email protected]>
AuthorDate: Wed Sep 25 12:12:12 2019 +0200

    EMPIREDB-307
    Make TagEncodingHelper overridable
---
 empire-db-examples/empire-db-example-jsf2/pom.xml  |   4 +-
 empire-db-jsf2/pom.xml                             |   4 +-
 .../apache/empire/jsf2/components/ControlTag.java  |   3 +-
 .../apache/empire/jsf2/components/InputTag.java    |   3 +-
 .../apache/empire/jsf2/components/LabelTag.java    |   3 +-
 .../org/apache/empire/jsf2/components/LinkTag.java |   3 +-
 .../apache/empire/jsf2/components/MenuListTag.java |   3 +-
 .../apache/empire/jsf2/components/SelectTag.java   |   2 +-
 .../apache/empire/jsf2/components/TabPageTag.java  |   3 +-
 .../apache/empire/jsf2/components/TabViewTag.java  |   3 +-
 .../apache/empire/jsf2/components/TitleTag.java    |   3 +-
 .../apache/empire/jsf2/components/ValueTag.java    |   3 +-
 .../empire/jsf2/controls/TextInputControl.java     |  10 +-
 .../empire/jsf2/utils/TagEncodingHelper.java       | 239 +++++++++++----------
 .../jsf2/utils/TagEncodingHelperFactory.java       |  54 +++++
 pom.xml                                            |   6 +-
 16 files changed, 211 insertions(+), 135 deletions(-)

diff --git a/empire-db-examples/empire-db-example-jsf2/pom.xml 
b/empire-db-examples/empire-db-example-jsf2/pom.xml
index 009a224..e60451d 100644
--- a/empire-db-examples/empire-db-example-jsf2/pom.xml
+++ b/empire-db-examples/empire-db-example-jsf2/pom.xml
@@ -73,8 +73,8 @@
 
                <!-- EL --> 
                <dependency>
-                   <groupId>org.apache.tomcat</groupId>
-                   <artifactId>tomcat-el-api</artifactId>
+                   <groupId>javax.el</groupId>
+                   <artifactId>javax.el-api</artifactId>
                        <type>jar</type>
                        <scope>provided</scope>
                </dependency>
diff --git a/empire-db-jsf2/pom.xml b/empire-db-jsf2/pom.xml
index e49618a..1ae3d8d 100644
--- a/empire-db-jsf2/pom.xml
+++ b/empire-db-jsf2/pom.xml
@@ -60,8 +60,8 @@
                </dependency>
                <!-- EL --> 
                <dependency>
-                   <groupId>org.apache.tomcat</groupId>
-                   <artifactId>tomcat-el-api</artifactId>
+                   <groupId>javax.el</groupId>
+                   <artifactId>javax.el-api</artifactId>
                        <type>jar</type>
                        <scope>provided</scope>
                </dependency>
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 91e7a77..4fbeb09 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
@@ -40,6 +40,7 @@ import 
org.apache.empire.db.exceptions.FieldIllegalValueException;
 import org.apache.empire.exceptions.EmpireException;
 import org.apache.empire.jsf2.controls.InputControl;
 import org.apache.empire.jsf2.utils.TagEncodingHelper;
+import org.apache.empire.jsf2.utils.TagEncodingHelperFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -221,7 +222,7 @@ public class ControlTag extends UIInput implements 
NamingContainer
 
     protected static final String     readOnlyState      = "readOnlyState";
 
-    protected final TagEncodingHelper helper             = new 
TagEncodingHelper(this, "eInput");
+    protected final TagEncodingHelper helper             = 
TagEncodingHelperFactory.create(this, "eInput");
 
     protected InputControl            control            = null;
     protected InputControl.InputInfo  inpInfo            = null;
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 e3ab79b..159c62c 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
@@ -38,6 +38,7 @@ import org.apache.empire.exceptions.EmpireException;
 import org.apache.empire.exceptions.InvalidArgumentException;
 import org.apache.empire.jsf2.controls.InputControl;
 import org.apache.empire.jsf2.utils.TagEncodingHelper;
+import org.apache.empire.jsf2.utils.TagEncodingHelperFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -50,7 +51,7 @@ public class InputTag extends UIInput implements 
NamingContainer
     // private static final String inputInfoPropName = 
InputControl.InputInfo.class.getSimpleName();
     protected static final String     readOnlyState      = "readOnlyState";
 
-    protected final TagEncodingHelper helper             = new 
TagEncodingHelper(this, "eInput");
+    protected final TagEncodingHelper helper             = 
TagEncodingHelperFactory.create(this, "eInput");
 
     protected InputControl            control            = null;
     protected InputControl.InputInfo  inpInfo            = null;
diff --git 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/LabelTag.java 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/LabelTag.java
index 9ec9d4b..4733a14 100644
--- 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/LabelTag.java
+++ 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/LabelTag.java
@@ -30,6 +30,7 @@ import javax.faces.context.FacesContext;
 import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.data.DataType;
 import org.apache.empire.jsf2.utils.TagEncodingHelper;
+import org.apache.empire.jsf2.utils.TagEncodingHelperFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -38,7 +39,7 @@ public class LabelTag extends UIOutput implements 
NamingContainer
     // Logger
     private static final Logger log = LoggerFactory.getLogger(LabelTag.class);
     
-    protected final TagEncodingHelper helper = new TagEncodingHelper(this, 
"eLabel");
+    protected final TagEncodingHelper helper = 
TagEncodingHelperFactory.create(this, "eLabel");
 
     private boolean creatingComponents = false;
     
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 eabb960..ed707d4 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
@@ -41,6 +41,7 @@ import org.apache.empire.jsf2.controls.InputControl;
 import org.apache.empire.jsf2.controls.InputControlManager;
 import org.apache.empire.jsf2.utils.StringResponseWriter;
 import org.apache.empire.jsf2.utils.TagEncodingHelper;
+import org.apache.empire.jsf2.utils.TagEncodingHelperFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -60,7 +61,7 @@ public class LinkTag extends UIOutput // implements 
NamingContainer
     // Logger
     private static final Logger log = LoggerFactory.getLogger(LinkTag.class);
     
-    protected final TagEncodingHelper helper = new TagEncodingHelper(this, 
"eLink");
+    protected final TagEncodingHelper helper = 
TagEncodingHelperFactory.create(this, "eLink");
 
     private boolean creatingComponents = false;
     
diff --git 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/MenuListTag.java
 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/MenuListTag.java
index 8689ef4..d840389 100644
--- 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/MenuListTag.java
+++ 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/MenuListTag.java
@@ -29,13 +29,14 @@ import javax.faces.context.ResponseWriter;
 
 import org.apache.empire.commons.StringUtils;
 import org.apache.empire.jsf2.utils.TagEncodingHelper;
+import org.apache.empire.jsf2.utils.TagEncodingHelperFactory;
 
 public class MenuListTag extends UIOutput implements NamingContainer
 {
     // Logger
     // private static final Logger log = 
LoggerFactory.getLogger(MenuTag.class);
     
-    protected final TagEncodingHelper helper = new TagEncodingHelper(this, 
"eMenuList");
+    protected final TagEncodingHelper helper = 
TagEncodingHelperFactory.create(this, "eMenuList");
     
     protected String currentId = null; 
     protected String currentClass = null; 
diff --git 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/SelectTag.java 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/SelectTag.java
index d8b7a00..cdd593b 100644
--- 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/SelectTag.java
+++ 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/SelectTag.java
@@ -223,7 +223,7 @@ public class SelectTag extends UIInput implements 
NamingContainer
         HtmlSelectOneMenu input = control.createMenuComponent(this);
         // css style
         String userStyle = 
StringUtils.toString(getAttributes().get("styleClass"));
-        String cssStyle = TagEncodingHelper.getTagStyleClass("eSelect", null, 
null, userStyle);
+        String cssStyle = 
TagEncodingHelper.assembleStyleClassString("eSelect", null, null, userStyle);
         input.setStyleClass(cssStyle);
         // other attributes
         copyAttributes(input);
diff --git 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TabPageTag.java
 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TabPageTag.java
index 41a47fe..031cf22 100644
--- 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TabPageTag.java
+++ 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TabPageTag.java
@@ -28,13 +28,14 @@ import javax.faces.context.ResponseWriter;
 
 import org.apache.empire.jsf2.controls.InputControl;
 import org.apache.empire.jsf2.utils.TagEncodingHelper;
+import org.apache.empire.jsf2.utils.TagEncodingHelperFactory;
 
 public class TabPageTag extends UIOutput implements NamingContainer
 {
     // Logger
     // private static final Logger log = 
LoggerFactory.getLogger(MenuTag.class);
     
-    protected final TagEncodingHelper helper = new TagEncodingHelper(this, 
"eTabPage");
+    protected final TagEncodingHelper helper = 
TagEncodingHelperFactory.create(this, "eTabPage");
 
     @Override
     public String getFamily()
diff --git 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TabViewTag.java
 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TabViewTag.java
index 584c8ba..d24204b 100644
--- 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TabViewTag.java
+++ 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TabViewTag.java
@@ -43,6 +43,7 @@ import org.apache.empire.jsf2.app.FacesUtils;
 import org.apache.empire.jsf2.controls.InputControl;
 import org.apache.empire.jsf2.controls.InputControlManager;
 import org.apache.empire.jsf2.utils.TagEncodingHelper;
+import org.apache.empire.jsf2.utils.TagEncodingHelperFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -60,7 +61,7 @@ public class TabViewTag extends UIOutput implements 
NamingContainer
 
     protected final String            TAB_RENDERED_ATTRIBUTE = "visible";
 
-    protected final TagEncodingHelper helper                 = new 
TagEncodingHelper(this, this.TAB_STYLE_CLASS);
+    protected final TagEncodingHelper helper                 = 
TagEncodingHelperFactory.create(this, this.TAB_STYLE_CLASS);
 
     public static class TabPageActionListener implements ActionListener, 
StateHolder
     {
diff --git 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TitleTag.java 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TitleTag.java
index b1f605f..f21d221 100644
--- 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TitleTag.java
+++ 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TitleTag.java
@@ -29,6 +29,7 @@ import org.apache.empire.commons.StringUtils;
 import org.apache.empire.data.Column;
 import org.apache.empire.exceptions.InvalidArgumentException;
 import org.apache.empire.jsf2.utils.TagEncodingHelper;
+import org.apache.empire.jsf2.utils.TagEncodingHelperFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -37,7 +38,7 @@ public class TitleTag extends UIOutput // implements 
NamingContainer
     // Logger
     private static final Logger log = LoggerFactory.getLogger(TitleTag.class);
     
-    protected final TagEncodingHelper helper = new TagEncodingHelper(this, 
"eTitle");
+    protected final TagEncodingHelper helper = 
TagEncodingHelperFactory.create(this, "eTitle");
 
     public TitleTag()
     {
diff --git 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ValueTag.java 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ValueTag.java
index dc7d13a..78c15d9 100644
--- 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ValueTag.java
+++ 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ValueTag.java
@@ -28,6 +28,7 @@ import org.apache.empire.commons.StringUtils;
 import org.apache.empire.data.DataType;
 import org.apache.empire.jsf2.controls.InputControl;
 import org.apache.empire.jsf2.utils.TagEncodingHelper;
+import org.apache.empire.jsf2.utils.TagEncodingHelperFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -37,7 +38,7 @@ public class ValueTag extends UIOutput // implements 
NamingContainer
     // Logger
     private static final Logger log = LoggerFactory.getLogger(ValueTag.class);
     
-    protected final TagEncodingHelper helper = new TagEncodingHelper(this, 
"eVal");
+    protected final TagEncodingHelper helper = 
TagEncodingHelperFactory.create(this, "eVal");
 
     public ValueTag()
     {
diff --git 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
index bbfbaea..0c57401 100644
--- 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
+++ 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
@@ -42,7 +42,6 @@ import org.apache.empire.data.Column;
 import org.apache.empire.data.DataType;
 import org.apache.empire.exceptions.InvalidArgumentException;
 import org.apache.empire.exceptions.UnexpectedReturnValueException;
-import org.apache.empire.jsf2.utils.TagEncodingHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -148,9 +147,12 @@ public class TextInputControl extends InputControl
         text.setValue(value);
         // wrap
         HtmlPanelGroup span = new HtmlPanelGroup();
-        String styleClass = TagEncodingHelper.getTagStyleClass(tagStyle, 
TagEncodingHelper.getDataTypeClass(ii.getColumn().getDataType()),
-                                                               null, null);
-        span.getAttributes().put("styleClass", styleClass);
+        /* 
+        --- dataTypeClass not needed --- 
+        String dataTypeClass = 
TagEncodingHelper.getDataTypeClass(ii.getColumn().getDataType()); 
+        String styleClass    = TagEncodingHelper.getTagStyleClass(tagStyle, 
dataTypeClass, null, null);
+        */
+        span.getAttributes().put("styleClass", tagStyle);
         span.getChildren().add(text);
         return span;
     }
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 9a0f73c..40eb08a 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
@@ -79,13 +79,11 @@ import org.slf4j.LoggerFactory;
 public class TagEncodingHelper implements NamingContainer
 {
     /**
-     * Inner class that implements the ValueInfo
-     * Only necessary because of name clash with value tag interface (i.e. 
getColumn())
-     * 
-     * @author Rainer
+     * ColumnExprWrapper
+     * wraps a ColumnExpr object into a Column interface object
+     * @author doebele
      */
-
-    private static class ColumnExprWrapper implements Column
+    protected static class ColumnExprWrapper implements Column
     {
         private final ColumnExpr expr;
 
@@ -180,7 +178,12 @@ public class TagEncodingHelper implements NamingContainer
         }
     }
 
-    private class ValueInfoImpl implements InputControl.ValueInfo
+    /**
+     * ValueInfoImpl
+     * Provides information necessary to render a data value (non editable) 
+     * @author doebele
+     */
+    protected class ValueInfoImpl implements InputControl.ValueInfo
     {
         public ValueInfoImpl(Column column, TextResolver resolver)
         {
@@ -191,7 +194,7 @@ public class TagEncodingHelper implements NamingContainer
         }
 
         /* Value Options */
-        private boolean hasColumn()
+        protected boolean hasColumn()
         {
             return (column != null || getColumn() != null);
         }
@@ -280,7 +283,12 @@ public class TagEncodingHelper implements NamingContainer
         }
     }
 
-    private class InputInfoImpl extends ValueInfoImpl implements 
InputControl.InputInfo
+    /**
+     * InputInfoImpl
+     * Provides information necessary to render an input control (editable) 
+     * @author doebele
+     */
+    protected class InputInfoImpl extends ValueInfoImpl implements 
InputControl.InputInfo
     {
         public InputInfoImpl(Column column, TextResolver resolver)
         {
@@ -379,36 +387,36 @@ public class TagEncodingHelper implements NamingContainer
     public static final String COLATTR_TOOLTIP        = "TOOLTIP";          // 
Column tooltip
     public static final String COLATTR_ABBR_TITLE     = "ABBR_TITLE";       // 
Column title for abbreviations
     
-    private final UIOutput      tag;
-    private final String        tagCssStyle;
-    private Column              column       = null;
-    private Object              record       = null;
-    private RecordTag           recordTag    = null;
-    // private Boolean          tagRequired  = null;
-    private Boolean             hasValueRef  = null;
-    private InputControl        control      = null;
-    private TextResolver        textResolver = null;
-    private Object              mostRecentValue = null;
-    private boolean             skipValidation = false;
-    private boolean             hasError     = false;
-    private Boolean             insideUIData = null;
-
-    public TagEncodingHelper(UIOutput tag, String tagCssStyle)
-    {
-        this.tag = tag;
-        this.tagCssStyle = tagCssStyle;
+    protected final UIOutput      component;
+    protected final String        cssStyleClass;
+    protected Column              column       = null;
+    protected Object              record       = null;
+    protected RecordTag           recordTag    = null;
+    // protected Boolean          tagRequired  = null;
+    protected Boolean             hasValueRef  = null;
+    protected InputControl        control      = null;
+    protected TextResolver        textResolver = null;
+    protected Object              mostRecentValue = null;
+    protected boolean             skipValidation = false;
+    protected boolean             hasError     = false;
+    protected Boolean             insideUIData = null;
+
+    protected TagEncodingHelper(UIOutput component, String cssStyleClass)
+    {
+        this.component = component;
+        this.cssStyleClass = cssStyleClass;
     }
 
     public void encodeBegin()
     {
-        if (tag instanceof UIInput)
+        if (component instanceof UIInput)
         {   // has local value?
-            if (((UIInput)tag).isLocalValueSet())
+            if (((UIInput)component).isLocalValueSet())
             {   /* clear local value */
                 if (log.isDebugEnabled())
-                    log.debug("clearing local value for {}. value is {}.", 
getColumnName(), ((UIInput)tag).getLocalValue());
-                ((UIInput)tag).setValue(null);
-                ((UIInput)tag).setLocalValueSet(false);
+                    log.debug("clearing local value for {}. value is {}.", 
getColumnName(), ((UIInput)component).getLocalValue());
+                ((UIInput)component).setValue(null);
+                ((UIInput)component).setLocalValueSet(false);
             }
             /*
             ValueExpression ve = findValueExpression("required", true);
@@ -421,8 +429,8 @@ public class TagEncodingHelper implements NamingContainer
         }
     }
     
-    private static final String PH_COLUMN_NAME = "{column}";  // placeholder 
for column name
-    private static final String PH_COLUMN_FULL = "{COLUMN}";  // placeholder 
for column full name including table
+    protected static final String PH_COLUMN_NAME = "{column}";  // placeholder 
for column name
+    protected static final String PH_COLUMN_FULL = "{COLUMN}";  // placeholder 
for column full name including table
 
     public String completeInputTagId(String id)
     {
@@ -474,8 +482,42 @@ public class TagEncodingHelper implements NamingContainer
         checkRecord();
         return control;
     }
+
+    protected InputControl detectInputControl(String controlType, DataType 
dataType, boolean hasOptions)
+    {
+        // Create
+        if (dataType==null)
+            throw new InvalidArgumentException("dataType", dataType);
+        // find control type
+        InputControl control = null;
+        if (StringUtils.isNotEmpty(controlType))
+            control = InputControlManager.getControl(controlType);
+        if (control == null)
+        {   // Auto-detect
+            if (hasOptions)
+                controlType = SelectInputControl.NAME;
+            else
+            {   // get from data type
+                switch (dataType)
+                {
+                    case CLOB:
+                        controlType = TextAreaInputControl.NAME;
+                        break;
+                    default:
+                        controlType = TextInputControl.NAME;
+                }
+            }
+            // get default control
+            control = InputControlManager.getControl(controlType);
+            // Still not? Use Text Control
+            if (control == null)
+                control = 
InputControlManager.getControl(TextInputControl.NAME);
+        }
+        // check record
+        return control;
+    }
     
-    private void checkRecord()
+    protected void checkRecord()
     {
         // Record may change even for the same instance
         if (this.record== null)
@@ -493,11 +535,11 @@ public class TagEncodingHelper implements NamingContainer
                         String keyOld = 
StringUtils.toString(((DBRecord)this.record).getKeyValues());
                         String keyNew = 
StringUtils.toString(((DBRecord)rec).getKeyValues());
                         String rowSet = 
StringUtils.valueOf(((DBRecord)rec).getRowSet().getName());
-                        log.trace("Changing "+tag.getClass().getSimpleName()+" 
record of rowset "+rowSet+" from {} to {}", keyOld, keyNew);
+                        log.trace("Changing 
"+component.getClass().getSimpleName()+" record of rowset "+rowSet+" from {} to 
{}", keyOld, keyNew);
                     }
                     else
                     {   // probably a bean change
-                        log.trace("Changing "+tag.getClass().getSimpleName()+" 
record of class "+rec.getClass().getSimpleName());
+                        log.trace("Changing 
"+component.getClass().getSimpleName()+" record of class 
"+rec.getClass().getSimpleName());
                     }
                 }
                 // change now
@@ -593,7 +635,7 @@ public class TagEncodingHelper implements NamingContainer
         if (record != null || (record=getTagAttributeValue("record"))!=null)
             return null; // No record tag: Record has been specified!
         // walk upwards the parent component tree and return the first record 
component found (if any)
-        UIComponent parent = tag;
+        UIComponent parent = component;
         while ((parent = parent.getParent()) != null)
         {
             if (parent instanceof RecordTag)
@@ -605,7 +647,7 @@ public class TagEncodingHelper implements NamingContainer
         return null;
     }
 
-    private boolean isDetectFieldChange()
+    protected boolean isDetectFieldChange()
     {
         Object v = this.getTagAttributeValue("detectFieldChange");
         if (v==null && recordTag != null)
@@ -631,11 +673,11 @@ public class TagEncodingHelper implements NamingContainer
         else
         {   // Get from tag
             if (evalExpression)
-                return tag.getValue();
+                return component.getValue();
             else
             {   // return value or value expression
-                Object value = tag.getLocalValue();
-                if (value!=null && (tag instanceof UIInput) && 
!((UIInput)tag).isLocalValueSet())
+                Object value = component.getLocalValue();
+                if (value!=null && (component instanceof UIInput) && 
!((UIInput)component).isLocalValueSet())
                     value= null; /* should never come here! */
                 if (value==null)
                     value = findValueExpression("value", false);
@@ -708,7 +750,7 @@ public class TagEncodingHelper implements NamingContainer
         else
         { // Get from tag
           // tag.setValue(value);
-            ValueExpression ve = tag.getValueExpression("value");
+            ValueExpression ve = component.getValueExpression("value");
             if (ve == null)
                 throw new PropertyReadOnlyException("value");
 
@@ -720,7 +762,7 @@ public class TagEncodingHelper implements NamingContainer
     public boolean isRecordReadOnly()
     {
         // Check tag
-        if (!(tag instanceof UIInput))
+        if (!(component instanceof UIInput))
             return true;
         // check attribute
         Object val = getTagAttributeValue("readonly");
@@ -852,7 +894,7 @@ public class TagEncodingHelper implements NamingContainer
         // When null, try value
         if (col == null)
         { // Try value
-            col = tag.getValue();
+            col = component.getValue();
             // Column supplied?
             if (col instanceof Column)
             {
@@ -865,14 +907,19 @@ public class TagEncodingHelper implements NamingContainer
                 if (source != null)
                     return source;
                 // No source column? --> wrap 
-                return new ColumnExprWrapper((ColumnExpr) col);
+                return createColumnExprWrapper((ColumnExpr) col);
             }
         }
         // No column!
-        if (log.isDebugEnabled() && !(tag instanceof LinkTag))
+        if (log.isDebugEnabled() && !(component instanceof LinkTag))
             log.warn("No Column provided for value tag!");
         return null;
     }
+    
+    protected Column createColumnExprWrapper(ColumnExpr colExpr)
+    {
+         return new ColumnExprWrapper(colExpr);
+    }
 
     protected Object findRecord()
     {
@@ -892,8 +939,8 @@ public class TagEncodingHelper implements NamingContainer
         }
         else
         {   // not supplied
-            if ((tag instanceof ControlTag) && 
!((ControlTag)tag).isCustomInput())
-                log.warn("No record supplied for {} and column {}.", 
tag.getClass().getSimpleName(), getColumnName());
+            if ((component instanceof ControlTag) && 
!((ControlTag)component).isCustomInput())
+                log.warn("No record supplied for {} and column {}.", 
component.getClass().getSimpleName(), getColumnName());
         }
         return rec;
     }
@@ -926,17 +973,17 @@ public class TagEncodingHelper implements NamingContainer
         return hasValueRef.booleanValue();
     }
     
-    private static final String CC_ATTR_EXPR = "#{cc.attrs.";
+    protected static final String CC_ATTR_EXPR = "#{cc.attrs.";
     
     @SuppressWarnings("unchecked")
     protected ValueExpression findValueExpression(String attribute, boolean 
allowLiteral)
     {
         // Check for expression
-        ValueExpression ve = tag.getValueExpression(attribute);
+        ValueExpression ve = component.getValueExpression(attribute);
         if (ve == null)
             return null;
         // Find expression
-        UIComponent parent = tag;
+        UIComponent parent = component;
         String expr = ve.getExpressionString();
         while (expr.startsWith(CC_ATTR_EXPR))
         {
@@ -1157,9 +1204,9 @@ public class TagEncodingHelper implements NamingContainer
         return textResolver;
     }
     
-    private boolean detectError(FacesContext context)
+    protected boolean detectError(FacesContext context)
     {
-        Iterator<FacesMessage> iter = context.getMessages(tag.getClientId());
+        Iterator<FacesMessage> iter = 
context.getMessages(component.getClientId());
         while (iter.hasNext())
         {   // Check for error
             FacesMessage m = iter.next();
@@ -1173,7 +1220,7 @@ public class TagEncodingHelper implements NamingContainer
     {
         String msgText = getTextResolver(context).getExceptionMessage(e);
         FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, 
msgText, msgText);
-        context.addMessage(tag.getClientId(), msg);
+        context.addMessage(component.getClientId(), msg);
     }
 
     public Object getAttributeValueEx(String name)
@@ -1216,7 +1263,7 @@ public class TagEncodingHelper implements NamingContainer
     
     public Object getTagAttributeValue(String name)
     {
-        return TagEncodingHelper.getTagAttributeValue(tag, name);
+        return TagEncodingHelper.getTagAttributeValue(component, name);
     }
 
     public static Object getTagAttributeValue(UIComponent comp, String name)
@@ -1284,7 +1331,7 @@ public class TagEncodingHelper implements NamingContainer
         {   // find the component
             if (!forInput.equals("*"))
             {   // Set Label input Id
-                UIComponent input = 
FacesUtils.getWebApplication().findComponent(context, forInput, tag);
+                UIComponent input = 
FacesUtils.getWebApplication().findComponent(context, forInput, component);
                 if (input!=null && (input instanceof InputTag))
                 {   // Check Read-Only
                     InputTag inputTag = ((InputTag)input);
@@ -1369,7 +1416,7 @@ public class TagEncodingHelper implements NamingContainer
         InputTag inputTag = null;
         if (StringUtils.isNotEmpty(forInput) && !forInput.equals("*"))
         {   // Set Label input Id
-            UIComponent input = 
FacesUtils.getWebApplication().findComponent(context, forInput, tag);
+            UIComponent input = 
FacesUtils.getWebApplication().findComponent(context, forInput, component);
             if (input!=null && (input instanceof InputTag))
             {   // Check Read-Only
                 inputTag = ((InputTag)input);
@@ -1398,22 +1445,24 @@ public class TagEncodingHelper implements 
NamingContainer
     
     /* ********************** CSS-generation ********************** */
 
-    public static final String getTagStyleClass(String tagCssStyle, String 
typeClass, String addlStyle, String userStyle)
+    public static final String assembleStyleClassString(String tagCssStyle, 
String typeClass, String addlStyle, String userStyle)
     {
-        // tag and type style class
+        // handle simple case
         if (StringUtils.isEmpty(userStyle) && StringUtils.isEmpty(addlStyle))
             return StringUtils.isEmpty(typeClass) ? tagCssStyle : tagCssStyle 
+ typeClass;
-        // concatenate
+        // assemble 
         StringBuilder b = new StringBuilder(tagCssStyle);
         if (StringUtils.isNotEmpty(typeClass))
+        {   // type class must begin with a space!
             b.append(typeClass);
+        }
         if (StringUtils.isNotEmpty(addlStyle))
-        {
+        {   // add additional style class
             b.append(" ");
             b.append(addlStyle);
         }
         if (StringUtils.isNotEmpty(userStyle) && 
!StringUtils.compareEqual(userStyle, addlStyle, false))
-        {
+        {   // add user style class
             b.append(" ");
             b.append(userStyle);
         }
@@ -1428,7 +1477,7 @@ public class TagEncodingHelper implements NamingContainer
     public static final String CSS_DATA_TYPE_DATE     = " eTypeDate";
     public static final String CSS_DATA_TYPE_BOOL     = " eTypeBool";
 
-    public static final String getDataTypeClass(DataType type)
+    protected String getDataTypeClass(DataType type)
     {
         switch (type)
         {
@@ -1455,35 +1504,31 @@ public class TagEncodingHelper implements 
NamingContainer
         }
     }
 
-    public final String getTagStyleClass(DataType dataType, String addlStyle, 
String userStyle)
+    public String getTagStyleClass(DataType dataType, String addlStyle, String 
userStyle)
     {
-        String typeClass = getDataTypeClass(dataType);
+        String typeClass = (dataType!=null) ? getDataTypeClass(dataType) : 
null;
         String contextStyle = getContextStyleClass(addlStyle);
-        return getTagStyleClass(tagCssStyle, typeClass, contextStyle, 
userStyle);
+        return assembleStyleClassString(cssStyleClass, typeClass, 
contextStyle, userStyle);
     }
 
-    public final String getTagStyleClass(DataType dataType, String addlStyle)
+    public String getTagStyleClass(DataType dataType, String addlStyle)
     {
         String userStyle = getTagAttributeStringEx("styleClass");
-        String typeClass = getDataTypeClass(dataType);
-        return getTagStyleClass(tagCssStyle, typeClass, addlStyle, userStyle);
+        return getTagStyleClass(dataType, addlStyle, userStyle);
     }
 
-    public final String getTagStyleClass(String addlStyle)
+    public String getTagStyleClass(String addlStyle)
     {
-        String userStyle = getTagAttributeStringEx("styleClass");
-        String typeClass = hasColumn() ? 
getDataTypeClass(column.getDataType()) : null;
-        return getTagStyleClass(tagCssStyle, typeClass, addlStyle, userStyle);
+        DataType dataType = (hasColumn() ? column.getDataType() : null);
+        return getTagStyleClass(dataType, addlStyle);
     }
 
     public final String getTagStyleClass()
     {
-        String userStyle = getTagAttributeStringEx("styleClass");
-        String typeClass = hasColumn() ? 
getDataTypeClass(column.getDataType()) : null;
-        return getTagStyleClass(tagCssStyle, typeClass, null, userStyle);
+        return getTagStyleClass((String)null);
     }
     
-    private final String getContextStyleClass(String addlStyle)
+    protected String getContextStyleClass(String addlStyle)
     {
         String contextStyle = null;
         if ((getRecord() instanceof TagContextInfo) && hasColumn())
@@ -1503,13 +1548,13 @@ public class TagEncodingHelper implements 
NamingContainer
     
     public boolean isInsideUIData()
     {
-        if (tag==null)
+        if (component==null)
             return false;
         if (this.insideUIData!=null)
             return this.insideUIData;
         // detect
         this.insideUIData = false;
-        for (UIComponent p = tag.getParent(); p!=null; p=p.getParent())
+        for (UIComponent p = component.getParent(); p!=null; p=p.getParent())
         {   // Check whether inside UIData
             if (p instanceof UIData) {
                 this.insideUIData = true;
@@ -1561,39 +1606,5 @@ public class TagEncodingHelper implements NamingContainer
             */
         }
     }
-
-    private static InputControl detectInputControl(String controlType, 
DataType dataType, boolean hasOptions)
-    {
-        // Create
-        if (dataType==null)
-            throw new InvalidArgumentException("dataType", dataType);
-        // find control type
-        InputControl control = null;
-        if (StringUtils.isNotEmpty(controlType))
-            control = InputControlManager.getControl(controlType);
-        if (control == null)
-        {   // Auto-detect
-            if (hasOptions)
-                controlType = SelectInputControl.NAME;
-            else
-            {   // get from data type
-                switch (dataType)
-                {
-                    case CLOB:
-                        controlType = TextAreaInputControl.NAME;
-                        break;
-                    default:
-                        controlType = TextInputControl.NAME;
-                }
-            }
-            // get default control
-            control = InputControlManager.getControl(controlType);
-            // Still not? Use Text Control
-            if (control == null)
-                control = 
InputControlManager.getControl(TextInputControl.NAME);
-        }
-        // check record
-        return control;
-    }
     
 }
diff --git 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelperFactory.java
 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelperFactory.java
new file mode 100644
index 0000000..5aa9f53
--- /dev/null
+++ 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelperFactory.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.jsf2.utils;
+
+import javax.faces.component.UIOutput;
+
+public abstract class TagEncodingHelperFactory
+{
+    /**
+     * DefaultTagEncodingHelperFactory
+     * Factory creating instances of TagEncodingHelper
+     * @author doebele
+     */
+    private static class DefaultTagEncodingHelperFactory extends 
TagEncodingHelperFactory
+    {
+        @Override
+        protected TagEncodingHelper newInstance(UIOutput component, String 
cssStyleClass)
+        {
+            return new TagEncodingHelper(component, cssStyleClass);
+        }
+    }
+    
+    private static TagEncodingHelperFactory factory = new 
DefaultTagEncodingHelperFactory();
+    
+    public static TagEncodingHelperFactory setFactory(TagEncodingHelperFactory 
newFactory)
+    {
+        TagEncodingHelperFactory previous = factory;
+        factory = newFactory;
+        return previous;
+    }
+    
+    public static TagEncodingHelper create(UIOutput component, String 
cssStyleClass)
+    {
+        return factory.newInstance(component, cssStyleClass);
+    }
+    
+    protected abstract TagEncodingHelper newInstance(UIOutput component, 
String cssStyleClass);
+}
diff --git a/pom.xml b/pom.xml
index c4c8368..810058c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -371,9 +371,9 @@
                                <version>2.2.12</version>
                        </dependency>
                        <dependency>
-                           <groupId>org.apache.tomcat</groupId>
-                           <artifactId>tomcat-el-api</artifactId>
-                           <version>8.0.48</version>
+                           <groupId>javax.el</groupId>
+                           <artifactId>javax.el-api</artifactId>
+                           <version>3.0.0</version>
                        </dependency>
                <!-- Misc -->
                        <dependency>

Reply via email to