empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1345163 - in /empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2: components/ controls/ utils/
Date Fri, 01 Jun 2012 13:24:02 GMT
Author: doebele
Date: Fri Jun  1 13:24:01 2012
New Revision: 1345163

URL: http://svn.apache.org/viewvc?rev=1345163&view=rev
Log:
EMPIREDB-140
various bugfixes for tag encoding

Modified:
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ControlTag.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/InputTag.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextAreaInputControl.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ControlTag.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ControlTag.java?rev=1345163&r1=1345162&r2=1345163&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ControlTag.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ControlTag.java
Fri Jun  1 13:24:01 2012
@@ -383,9 +383,10 @@ public class ControlTag extends UIInput 
     {
         // check for record
         if (helper.getRecord()!=null)
-            helper.getDataValue();
+            return helper.getDataValue(true);
         // default
-        return super.getValue();
+        Object value = super.getValue();
+        return value; 
     }
 
     @Override

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/InputTag.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/InputTag.java?rev=1345163&r1=1345162&r2=1345163&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/InputTag.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/InputTag.java
Fri Jun  1 13:24:01 2012
@@ -110,9 +110,10 @@ public class InputTag extends UIInput im
     {
         // check for record
         if (helper.getRecord()!=null)
-            helper.getDataValue();
+            return helper.getDataValue(true);
         // default
-        return super.getValue();
+        Object value = super.getValue(); 
+        return value; 
     }
 
     @Override

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java?rev=1345163&r1=1345162&r2=1345163&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java
Fri Jun  1 13:24:01 2012
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.util.List;
 import java.util.Locale;
 
+import javax.el.ValueExpression;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIInput;
 import javax.faces.context.FacesContext;
@@ -172,7 +173,7 @@ public abstract class InputControl
     {
         Column getColumn();
         Options getOptions();
-        Object getValue();
+        Object getValue(boolean evalExpression);
         String getFormat();    // Custom Formatting options specific to each InputControl-type
         Locale getLocale();
         String getText(String key);
@@ -256,6 +257,17 @@ public abstract class InputControl
         // Get value from Input
         return (submitted) ? input.getSubmittedValue() : input.getValue();        
     }
+
+    protected void setInputValue(UIInput input, InputInfo ii)
+    {
+        Object value = ii.getValue(false);
+        if (value instanceof ValueExpression)
+        {   input.setLocalValueSet(false);
+            input.setValueExpression("value", (ValueExpression)value);
+        }    
+        else
+            input.setValue(value);
+    }    
     
     /* validate 
     public boolean validateValue(UIComponent comp, InputInfo ii, FacesContext context)
@@ -394,7 +406,7 @@ public abstract class InputControl
     protected final String formatValue(ValueInfo vi)
     {
         boolean hasError = false; // ((vi instanceof InputInfo) && !((InputInfo)vi).isValid());

-        return formatValue(vi.getValue(), vi, hasError);
+        return formatValue(vi.getValue(true), vi, hasError);
     }
     
     /**

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java?rev=1345163&r1=1345162&r2=1345163&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java
Fri Jun  1 13:24:01 2012
@@ -80,8 +80,8 @@ public class SelectInputControl extends 
             }
         }
         
-        input.setValue(ii.getValue());
         input.setDisabled(ii.isDisabled());
+        setInputValue(input, ii);
         
         compList.add(input);
     }

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextAreaInputControl.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextAreaInputControl.java?rev=1345163&r1=1345162&r2=1345163&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextAreaInputControl.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextAreaInputControl.java
Fri Jun  1 13:24:01 2012
@@ -73,7 +73,7 @@ public class TextAreaInputControl extend
             input.setRows(rows);
         
         input.setDisabled(ii.isDisabled());
-        input.setValue(ii.getValue());
+        setInputValue(input, ii);
         
         compList.add(input);
     }

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java?rev=1345163&r1=1345162&r2=1345163&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
Fri Jun  1 13:24:01 2012
@@ -103,7 +103,7 @@ public class TextInputControl extends In
         */    
             
         input.setDisabled(ii.isDisabled()); //  || ii.getColumn().isAutoGenerated()
-        input.setValue(ii.getValue());
+        setInputValue(input, ii);
         
         compList.add(input);
     }

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java?rev=1345163&r1=1345162&r2=1345163&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
Fri Jun  1 13:24:01 2012
@@ -186,9 +186,9 @@ public class TagEncodingHelper implement
         }
 
         @Override
-        public Object getValue()
+        public Object getValue(boolean evalExpression)
         {
-            return getDataValue();
+            return getDataValue(evalExpression);
         }
 
         @Override
@@ -252,20 +252,6 @@ public class TagEncodingHelper implement
         }
 
         @Override
-        public Object getValue()
-        {
-            /*
-            if (tag instanceof UIInput)
-            {
-                UIInput t = ((UIInput)tag);
-                Object  v = t.getValue();
-                log.info("tag Value =" + String.valueOf(v));
-            }
-            */
-            return getDataValue();
-        }
-
-        @Override
         public void setValue(Object value)
         {
             setDataValue(value);
@@ -274,7 +260,7 @@ public class TagEncodingHelper implement
         @Override
         public void validate(Object value)
         {
-            // Make sure null values are not foced to be required
+            // Make sure null values are not forced to be required
             boolean isNull = ObjectUtils.isEmpty(value);
             if (isNull && !isRequired())
                 return;
@@ -439,7 +425,7 @@ public class TagEncodingHelper implement
         return null;
     }
 
-    public Object getDataValue()
+    public Object getDataValue(boolean evalExpression)
     {
         if (getRecord() != null)
         { // value
@@ -454,8 +440,18 @@ public class TagEncodingHelper implement
             }
         }
         else
-        { // Get from tag
-            return tag.getValue();
+        {   // Get from tag
+            if (evalExpression)
+                return tag.getValue();
+            else
+            {   // return value or value expression
+                Object value = tag.getLocalValue();
+                if (value==null)
+                    value = findValueExpression();
+                
+                // value = tag.getValue();
+                return value;
+            }
         }
     }
 
@@ -673,6 +669,8 @@ public class TagEncodingHelper implement
         hasValueExpr = new Boolean(ve != null);
         return hasValueExpr.booleanValue();
     }
+    
+    private static final String CC_ATTR_EXPR = "#{cc.attrs.";
 
     protected ValueExpression findValueExpression()
     {
@@ -683,13 +681,16 @@ public class TagEncodingHelper implement
         // Find expression
         UIComponent parent = tag;
         String expr = ve.getExpressionString();
-        while (expr.equals("#{cc.attrs.value}"))
+        while (expr.startsWith(CC_ATTR_EXPR))
         {
+            // find parent
             parent = UIComponent.getCompositeComponentParent(parent);
             if (parent == null)
                 return null;
             // check expression
-            ve = parent.getValueExpression("value");
+            int end = expr.indexOf('}');
+            String attrib = expr.substring(CC_ATTR_EXPR.length(), end);
+            ve = parent.getValueExpression(attrib);
             if (ve == null)
                 return null;
             // get new expression String
@@ -698,7 +699,7 @@ public class TagEncodingHelper implement
         // found
         return ve;
     }
-
+    
     protected Options getValueOptions()
     {
         // null value
@@ -788,7 +789,7 @@ public class TagEncodingHelper implement
         String templ = StringUtils.valueOf(value);
         int valIndex = templ.indexOf("{}");
         if (valIndex >= 0)
-            value = getDataValue();
+            value = getDataValue(true);
         // Check Options
         String text;
         Options options = getValueOptions();
@@ -872,27 +873,29 @@ public class TagEncodingHelper implement
 
     protected String getLabelValue(Column column, boolean colon)
     {
-        String title=null;
+        String label = getTagAttribute("label");
+        if (label!=null)
+            return label;
         // Check for short form    
         if (hasFormat("short"))
         {
-            title = StringUtils.toString(column.getAttribute(COLATTR_ABBR_TITLE));
-            if (title==null)
+            label = StringUtils.toString(column.getAttribute(COLATTR_ABBR_TITLE));
+            if (label==null)
                 log.warn("No Abbreviation available for column {}. Using normal title.",
column.getName());
         }
         // Use normal title
-        if (title==null)
-            title=column.getTitle();
+        if (label==null)
+            label=column.getTitle();
         // translate
-        title = getDisplayText(title);
+        label = getDisplayText(label);
         // handle empty string
-        if (StringUtils.isEmpty(title))
+        if (StringUtils.isEmpty(label))
             return "";
         // getColon
         if (colon) 
-            title = title.trim() + ":";
+            label = label.trim() + ":";
         // done
-        return title;
+        return label;
     }
     
     public HtmlOutputLabel createLabelComponent(FacesContext context, String forInput, String
styleClass, String style, boolean colon)
@@ -933,7 +936,11 @@ public class TagEncodingHelper implement
         }
         
         // value
-        label.setValue(getLabelValue(column, colon));
+        String labelText = getLabelValue(column, colon);
+        if (StringUtils.isEmpty(labelText))
+            label.setRendered(false);
+        else
+            label.setValue(labelText);
 
         // styleClass
         if (StringUtils.isNotEmpty(styleClass))



Mime
View raw message