You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ja...@apache.org on 2010/07/19 12:11:12 UTC

svn commit: r965409 - in /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets: el/CompositeComponentELUtils.java tag/TagAttributeImpl.java

Author: jakobk
Date: Mon Jul 19 10:11:11 2010
New Revision: 965409

URL: http://svn.apache.org/viewvc?rev=965409&view=rev
Log:
MYFACES-2826 NPE when using the new UEL inside a composite component in Glassfish 3.0.1

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/el/CompositeComponentELUtils.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagAttributeImpl.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/el/CompositeComponentELUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/el/CompositeComponentELUtils.java?rev=965409&r1=965408&r2=965409&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/el/CompositeComponentELUtils.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/el/CompositeComponentELUtils.java Mon Jul 19 10:11:11 2010
@@ -57,6 +57,21 @@ public final class CompositeComponentELU
     public static final String CC_EXPRESSION_REGEX = ".*[^\\w\\.]cc[^\\w].*";
     
     /**
+     * A regular expression used to determine if cc.attrs is used as a method expression
+     * in an expression String. This means cc.attrs must occur, must stand before a '(',
+     * because otherwise it would be a method parameter (EL 2.2), and there must be no '.' after
+     * cc.attrs unless there is a left parenthesis before it (e.g. #{cc.attrs.method(bean.parameter)}).
+     * 
+     * Explanation of the parts:
+     * - [^\\(]* - There can be any character except a '(' before cc.attrs
+     * - [^\\w\\.\\(] - There must be no word character, dot, or left parenthesis directly before cc.attrs
+     * - cc\\.attrs\\. - "cc.attrs." must occur
+     * - [^\\.]* - There must be no dot after cc.attrs to indicate a method invocation on cc.attrs
+     * - (\\(.*)? - If there is a left paranthesis after cc.attrs, a dot is allowed again
+     */
+    public static final String CC_ATTRS_METHOD_EXPRESSION_REGEX = "[^\\(]*[^\\w\\.\\(]cc\\.attrs\\.[^\\.]*(\\(.*)?";
+    
+    /**
      * private constructor
      */
     private CompositeComponentELUtils()
@@ -154,4 +169,17 @@ public final class CompositeComponentELU
         return expression.matches(CC_EXPRESSION_REGEX);
     }
     
+    /**
+     * Tests if cc.attrs is used as a method expression in an expression String. This means 
+     * cc.attrs must occur, must stand before a '(', because otherwise it would be a method parameter 
+     * (EL 2.2), and there must be no '.' after cc.attrs unless there is a left parenthesis
+     * before it (e.g. #{cc.attrs.method(bean.parameter)}).
+     * @param expression
+     * @return
+     */
+    public static boolean isCompositeComponentAttrsMethodExpression(String expression)
+    {
+        return expression.matches(CC_ATTRS_METHOD_EXPRESSION_REGEX);
+    }
+    
 }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagAttributeImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagAttributeImpl.java?rev=965409&r1=965408&r2=965409&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagAttributeImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagAttributeImpl.java Mon Jul 19 10:11:11 2010
@@ -165,7 +165,9 @@ public final class TagAttributeImpl exte
             // From this point we can suppose this attribute contains a ELExpression
             // Now we have to check if the expression points to a composite component attribute map
             // and if so deal with it as an indirection.
-            if (isCompositeComponentAttributeMapExpression())
+            // NOTE that we have to check if the expression refers to cc.attrs for a MethodExpression
+            // (#{cc.attrs.myMethod}) or only for MethodExpression parameters (#{bean.method(cc.attrs.value)}).
+            if (CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression(this.getValue()))
             {
                 // The MethodExpression is on parent composite component attribute map.
                 // create a pointer that are referred to the real one that is created in other side
@@ -197,27 +199,6 @@ public final class TagAttributeImpl exte
         }
     }
     
-    private boolean isCompositeComponentAttributeMapExpression()
-    {
-        // Check if the ELExpression inside this.value has as target the composite component attribute map
-        // and if so, return true, otherwise return false. 
-        int i = this.value.indexOf("cc.");
-        if (i >= 0)
-        {
-            i = this.value.indexOf("attrs.",i+3); 
-            if (i >= 0)
-            {
-                // If the last target is a value inside the composite attribute map
-                // we are in case.
-                if (this.value.indexOf('.',i+6) < 0)
-                {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-    
     /**
      * The resolved Namespace for this attribute
      *