myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jak...@apache.org
Subject svn commit: r938466 - in /myfaces/core/trunk: api/src/main/java/javax/faces/component/_ComponentAttributesMap.java impl/src/main/java/org/apache/myfaces/el/unified/resolver/CompositeComponentELResolver.java
Date Tue, 27 Apr 2010 14:17:01 GMT
Author: jakobk
Date: Tue Apr 27 14:17:01 2010
New Revision: 938466

URL: http://svn.apache.org/viewvc?rev=938466&view=rev
Log:
MYFACES-2677 Adapt CompositeComponentAttributesMapWrapper to changes from MYFACES-2633

Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/CompositeComponentELResolver.java

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java?rev=938466&r1=938465&r2=938466&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java
(original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java
Tue Apr 27 14:17:01 2010
@@ -33,7 +33,6 @@ import java.util.WeakHashMap;
 
 import javax.el.ValueExpression;
 import javax.faces.FacesException;
-import javax.faces.application.Resource;
 import javax.faces.context.FacesContext;
 
 /**
@@ -244,17 +243,6 @@ class _ComponentAttributesMap implements
                 ValueExpression ve = _component.getValueExpression((String) key);
                 if (ve != null)
                 {
-                    //if (getUnderlyingMap().get ("org.apache.myfaces.COMPOSITE_COMPONENT_GET_VALUE_EXPRESSION")
!= null)
-                    //{
-                        // FIXME: this is "technically" a hack for the composite component
attribute
-                        // EL resolver.  #{cc.attrs} is supposed to wrap this map and call
getValue()
-                        // and setValue() on the ValueExpressions it returns... but the spec
says that
-                        // this method always needs to evaluate ValueExpressions, and therefore
the EL
-                        // resolver never even gets to see ValuExpressions.
-                        
-                    //    return ve;
-                    //}
-                    
                     value = ve.getValue(FacesContext.getCurrentInstance().getELContext());
                 }
                 else
@@ -265,15 +253,6 @@ class _ComponentAttributesMap implements
             }
         }
         
-        // The get() method of the Map must take the following additional action if this
component instance is a 
-        // composite component instance (indicated by the presence of a component attribute
under the key given 
-        // by the value of Resource.COMPONENT_RESOURCE_KEY)
-        // if (value instanceof ValueExpression && getUnderlyingMap().containsKey(Resource.COMPONENT_RESOURCE_KEY))
-        //{
-            // call the ValueExpression.getValue(javax.el.ELContext) method and return the
result from get().
-        //    value = ((ValueExpression)value).getValue(FacesContext.getCurrentInstance().getELContext());
-        //}
-        
         // Otherwise, return the actual value from the get() method. 
         return value;
     }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/CompositeComponentELResolver.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/CompositeComponentELResolver.java?rev=938466&r1=938465&r2=938466&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/CompositeComponentELResolver.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/unified/resolver/CompositeComponentELResolver.java
Tue Apr 27 14:17:01 2010
@@ -184,9 +184,8 @@ public final class CompositeComponentELR
     }
 
     // Wrapper map for composite component attributes.  Follows spec, section 5.6.2.2, table
5-11.
-    //
-    private final class CompositeComponentAttributesMapWrapper implements CompositeComponentExpressionHolder,
-            Map<String, Object>
+    private final class CompositeComponentAttributesMapWrapper 
+            implements CompositeComponentExpressionHolder, Map<String, Object>
     {
 
         private final UIComponent _component;
@@ -208,8 +207,8 @@ public final class CompositeComponentELR
         {
             ValueExpression valueExpr = _component.getValueExpression(name);
 
-            return ((valueExpr instanceof ValueExpression) ? (ValueExpression) valueExpr
-                    : null);
+            return ((valueExpr instanceof ValueExpression) 
+                    ? (ValueExpression) valueExpr : null);
         }
 
         public void clear()
@@ -234,20 +233,17 @@ public final class CompositeComponentELR
 
         public Object get(Object key)
         {
-            Object obj = getAsValueExpression (key);
-
-            // Per the spec, if the result is a ValueExpression, evaluate it and return the
value.
-
+            Object obj = _originalMap.get(key);
             if (obj != null)
             {
-                if (obj instanceof ValueExpression)
-                {
-                    return ((ValueExpression) obj).getValue(_elContext);
-                }
-                else
-                {
-                    return obj;                    
-                }
+                // _originalMap is a _ComponentAttributesMap and thus any
+                // ValueExpressions will be evaluated by the call to
+                // _originalMap.get(). The only case in which we really will
+                // get a ValueExpression here is when a ValueExpression itself
+                // is stored as an attribute. But in this case we really want to 
+                // get the ValueExpression. So we don't have to evaluate possible
+                // ValueExpressions here, but can return obj directly.
+                return obj;
             }
             else
             {
@@ -259,6 +255,9 @@ public final class CompositeComponentELR
                         break;
                     }
                 }
+                // We have to check for a ValueExpression and also evaluate it
+                // here, because in the PropertyDescriptor the default values are
+                // always stored as (Tag-)ValueExpressions.
                 if (obj != null && obj instanceof ValueExpression)
                 {
                     return ((ValueExpression) obj).getValue(_elContext);
@@ -270,28 +269,6 @@ public final class CompositeComponentELR
             }
         }
         
-        private Object getAsValueExpression (Object key)
-        {
-            Object obj;
-            
-            // FIXME: this is a hack, but I think it's necessary.  The component attributes
map
-            // that this class wraps requires that all ValueExpressions be evaluated before
they're
-            // returned, but the get() and put() methods defined in this class rely on ValueExpressions
-            // being returned so the underlying beans (if specified) can be updated with
new values.
-            // This may be something to notify the EG about.
-            
-            // The presence of this attribute will tell the component attributes map not
to evaluate
-            // ValueExpressions.
-            
-            //_originalMap.put (COMPOSITE_COMPONENT_GET_VALUE_EXPRESSION, Boolean.TRUE);
-            
-            obj = _originalMap.get (key);
-            
-            //_originalMap.remove (COMPOSITE_COMPONENT_GET_VALUE_EXPRESSION);
-            
-            return obj;
-        }
-        
         public boolean isEmpty()
         {
             return _originalMap.isEmpty();
@@ -304,20 +281,18 @@ public final class CompositeComponentELR
 
         public Object put(String key, Object value)
         {
-            Object obj = getAsValueExpression (key);
-
+            ValueExpression valueExpression = _component.getValueExpression(key);
+            
             // Per the spec, if the result is a ValueExpression, call setValue().
-
-            if ((obj != null) && (obj instanceof ValueExpression))
+            if (valueExpression != null)
             {
-                ((ValueExpression) obj).setValue(_elContext, value);
+                valueExpression.setValue(_elContext, value);
 
                 return null;
             }
 
-            // TODO: spec doesn't say.  I assume we just delegate instead of returning null...
-            // -= Leonardo Uribe =- Really this map is used to resolve ValueExpressions 
-            // like #{cc.attrs.somekey}, so the value returned is not expected to be used,

+            // Really this map is used to resolve ValueExpressions like 
+            // #{cc.attrs.somekey}, so the value returned is not expected to be used, 
             // but is better to delegate to keep the semantic of this method.
             return _originalMap.put(key, value);
         }



Mime
View raw message