public Object getTagAttributeValueEx()

in empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java [2109:2166]


    public Object getTagAttributeValueEx(String name, boolean isCssStyleClass)
    {
        /* 
         * Special handling of ControlTag "styleClass": Use it for control element only not for input element(s)
         */
        boolean useControlTagOverride = (InputControl.CSS_STYLE_CLASS.equals(name) && (this.component instanceof ControlTag) && isControlTagElementValid());
        Object value = getTagAttributeValue((useControlTagOverride ? "inputClass" : name));

        // Special "styleClass" append column attribute unless leading '-'
        boolean append = false;
        if (isCssStyleClass && (value instanceof String) && ((String)value).length()>0)
        {   // if value starts with '!' then do not append but replace
            if (((String)value).charAt(0)=='!')
                value = ((String)value).substring(1); // remove leadng '!'
            else if (((String)value).equals("-"))
                return null; // omit, if value is '-'
            else
                append = true; // append (default)
        }
        
        // Get column attribute
        if ((value==null || append) && hasColumn())
        {   // Check Column
            Object colValue = getColumnAttribute(name);
            if (append) 
            {   // append styles
                if (ObjectUtils.isNotEmpty(colValue) && !colValue.equals(value))
                    value = StringUtils.concat(colValue.toString(), " ", value.toString());
            }
            else 
            {   // replace
                value = colValue;
            }
        }
        
        // Checks whether it's another column    
        if (value instanceof Column)
        {   // Special case: Value is a column
            Column col = ((Column)value);
            Object rec = getRecord();
            if (rec instanceof Record)
                return ((Record)rec).get(col);
            else if (rec!=null)
            {   // Get Value from a bean
                String property = col.getBeanPropertyName();
                try
                {   // Use Beanutils to get Property
                    return BeanPropertyUtils.getProperty(rec, property);
                }
                catch (Exception e)
                {   log.error("BeanUtils.getProperty failed for property {} on {} ", property, rec.getClass().getName(), e);
                    return null;
                }
            }    
            return null;
        }
        return value;
    }