myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jak...@apache.org
Subject svn commit: r910208 - /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
Date Mon, 15 Feb 2010 12:02:17 GMT
Author: jakobk
Date: Mon Feb 15 12:02:16 2010
New Revision: 910208

URL: http://svn.apache.org/viewvc?rev=910208&view=rev
Log:
MYFACES-2558 composite:attributes action, actionListener, validator and valueChangeListener
don't need the attribute method-signature

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java?rev=910208&r1=910207&r2=910208&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
Mon Feb 15 12:02:16 2010
@@ -732,148 +732,150 @@
                 continue;
             }
             
+            String attributeName = propertyDescriptor.getName();
+            boolean isKnownMethod = "action".equals(attributeName) || "actionListener".equals(attributeName)
 
+                    || "validator".equals(attributeName) || "valueChangeListener".equals(attributeName);
+            
             // <composite:attribute> method-signature attribute is 
             // ValueExpression that must evaluate to String
-            ValueExpression methodSignatureExpression = 
-                (ValueExpression) propertyDescriptor.getValue("method-signature");
-            
+            ValueExpression methodSignatureExpression
+                    = (ValueExpression) propertyDescriptor.getValue("method-signature");
+            String methodSignature = null;
             if (methodSignatureExpression != null)
             {
                 // Check if the value expression holds a method signature
                 // Note that it could be null, so in that case we don't have to do anything
-                String methodSignature = (String) methodSignatureExpression.getValue(context.getELContext());
-                if (methodSignature != null)
+                methodSignature = (String) methodSignatureExpression.getValue(context.getELContext());
+            }
+            
+            // either the attributeName has to be a knownMethod or there has to be a method-signature
+            if (isKnownMethod || methodSignature != null)
+            {
+                ValueExpression targetsExpression = 
+                    (ValueExpression) propertyDescriptor.getValue("targets");
+                
+                String targets = null;
+                // <composite:attribute> targets attribute is 
+                // ValueExpression that must evaluate to String
+                if (targetsExpression != null)
                 {
-                    ValueExpression targetsExpression = 
-                        (ValueExpression) propertyDescriptor.getValue("targets");
-                    
-                    String attributeName = propertyDescriptor.getName();
-                    
-                    String targets = null;
-                    // <composite:attribute> targets attribute is 
-                    // ValueExpression that must evaluate to String
-                    if (targetsExpression != null)
-                    {
-                        targets = (String) targetsExpression.getValue(context.getELContext());
-                    }
-                    
-                    if (targets == null)
-                    {
-                        // "...let the name of the metadata element be the 
-                        // evaluated value of the targets attribute..."
-                        targets = attributeName; 
-                    }
-                    
-                    String [] targetsArray = StringUtils.splitShortString(targets, ' ');
-                    
-                    ValueExpression attributeNameValueExpression = 
-                        (ValueExpression) topLevelComponent.getAttributes().get(attributeName);
-                    
+                    targets = (String) targetsExpression.getValue(context.getELContext());
+                }
+                
+                if (targets == null)
+                {
+                    // "...let the name of the metadata element be the 
+                    // evaluated value of the targets attribute..."
+                    targets = attributeName; 
+                }
+                
+                ValueExpression attributeNameValueExpression = 
+                    (ValueExpression) topLevelComponent.getAttributes().get(attributeName);
+                
+                if (attributeNameValueExpression == null)
+                {
+                    // composite:attribute has a default property, so if we can't found on
the
+                    // component attribute map, we should get the default as CompositeComponentELResolver
+                    // does.
+                    attributeNameValueExpression = (ValueExpression) propertyDescriptor.getValue("default");
                     if (attributeNameValueExpression == null)
                     {
-                        // composite:attribute has a default property, so if we can't found
on the
-                        // component attribute map, we should get the default as CompositeComponentELResolver
-                        // does.
-                        attributeNameValueExpression = (ValueExpression) propertyDescriptor.getValue("default");
-                        if (attributeNameValueExpression == null)
+                        // It is only valid to log an error if the attribute is required
+                        ValueExpression ve = (ValueExpression) propertyDescriptor.getValue("required");
+                        if (ve != null)
                         {
-                            // It is only valid to log an error if the attribute is required
-                            ValueExpression ve = (ValueExpression) propertyDescriptor.getValue("required");
-                            if (ve != null)
+                            // QUESTION: Almost positive that the value expression is supposed
to evaluate to a boolean, but originally
+                            // the code assumed it to be a string.  Can someone verify what
the right type is?
+                            // ANS: -= Leonardo Uribe =- Take a look at AttributeHandler.
The correct type is Boolean, so we can cast safe 
+                            Boolean required = (Boolean) ve.getValue (context.getELContext());
+                            
+                            if (required != null && required.booleanValue())
                             {
-                                // QUESTION: Almost positive that the value expression is
supposed to evaluate to a boolean, but originally
-                                // the code assumed it to be a string.  Can someone verify
what the right type is?
-                                // ANS: -= Leonardo Uribe =- Take a look at AttributeHandler.
The correct type is Boolean, so we can cast safe 
-                                Boolean required = (Boolean) ve.getValue (context.getELContext());
-                                
-                                if (required != null && required.booleanValue())
-                                {
-                                    if (log.isLoggable(Level.SEVERE))
-                                        log.severe("attributeValueExpression not found under
the key \""+attributeName+
-                                                "\". Looking for the next attribute");
-                                }
+                                if (log.isLoggable(Level.SEVERE))
+                                    log.severe("attributeValueExpression not found under
the key \""+attributeName+
+                                            "\". Looking for the next attribute");
                             }
-                            continue;
                         }
+                        continue;
                     }
-                    
-                    String attributeExpressionString = attributeNameValueExpression.getExpressionString();
-                    MethodExpression methodExpression = null;
-                    
-                    if ("action".equals(attributeName) || "actionListener".equals(attributeName)
|| 
-                        "validator".equals(attributeName) || "valueChangeListener".equals(attributeName))
+                }
+                
+                String [] targetsArray = StringUtils.splitShortString(targets, ' ');
+                String attributeExpressionString = attributeNameValueExpression.getExpressionString();
+                MethodExpression methodExpression = null;
+                
+                if (isKnownMethod)
+                {
+                    for (String target : targetsArray)
                     {
-                        for (String target : targetsArray)
+                        UIComponent innerComponent = topLevelComponent.findComponent(target);
+                        
+                        if (innerComponent == null)
                         {
-                            UIComponent innerComponent = topLevelComponent.findComponent(target);
-                            
-                            if (innerComponent == null)
-                            {
-                                if (log.isLoggable(Level.SEVERE))
-                                    log.severe("Inner component "+target+"not found when
retargetMethodExpressions");
-                                continue;
-                            }
+                            if (log.isLoggable(Level.SEVERE))
+                                log.severe("Inner component " + target + " not found when
retargetMethodExpressions");
+                            continue;
+                        }
 
-                            if ("action".equals(attributeName))
-                            {
-                                // target is ActionSource2
-                                methodExpression = context.getApplication().getExpressionFactory().
+                        if ("action".equals(attributeName))
+                        {
+                            // target is ActionSource2
+                            methodExpression = context.getApplication().getExpressionFactory().
                                     createMethodExpression(context.getELContext(),
                                             attributeExpressionString, Object.class, new
Class[]{});
-                                
-                                ((ActionSource2)innerComponent).setActionExpression(methodExpression);
-                            }
-                            else if ("actionListener".equals(attributeName))
-                            {
-                               // target is ActionSource2
-                                methodExpression = context.getApplication().getExpressionFactory().
-                                createMethodExpression(context.getELContext(),
-                                        attributeExpressionString, Void.TYPE, new Class[]{ActionEvent.class});
-                                
-                                ((ActionSource)innerComponent).addActionListener(
-                                        new MethodExpressionActionListener(methodExpression));
-                            }
-                            else if ("validator".equals(attributeName))
-                            {
-                                // target is EditableValueHolder
-                                methodExpression = context.getApplication().getExpressionFactory().
-                                createMethodExpression(context.getELContext(),
+                            
+                            ((ActionSource2)innerComponent).setActionExpression(methodExpression);
+                        }
+                        else if ("actionListener".equals(attributeName))
+                        {
+                           // target is ActionSource2
+                            methodExpression = context.getApplication().getExpressionFactory().
+                                    createMethodExpression(context.getELContext(),
+                                            attributeExpressionString, Void.TYPE, new Class[]{ActionEvent.class});
+                            
+                            ((ActionSource)innerComponent).addActionListener(
+                                    new MethodExpressionActionListener(methodExpression));
+                        }
+                        else if ("validator".equals(attributeName))
+                        {
+                            // target is EditableValueHolder
+                            methodExpression = context.getApplication().getExpressionFactory().
+                                    createMethodExpression(context.getELContext(),
                                         attributeExpressionString, Void.TYPE, 
                                         new Class[]{FacesContext.class, UIComponent.class,
Object.class});
 
-                                ((EditableValueHolder)innerComponent).addValidator(
-                                        new MethodExpressionValidator(methodExpression));
-                            }
-                            else if ("valueChangeListener".equals(attributeName))
-                            {
-                                // target is EditableValueHolder
-                                methodExpression = context.getApplication().getExpressionFactory().
-                                createMethodExpression(context.getELContext(),
-                                        attributeExpressionString, Void.TYPE, 
-                                        new Class[]{ValueChangeEvent.class});
+                            ((EditableValueHolder)innerComponent).addValidator(
+                                    new MethodExpressionValidator(methodExpression));
+                        }
+                        else if ("valueChangeListener".equals(attributeName))
+                        {
+                            // target is EditableValueHolder
+                            methodExpression = context.getApplication().getExpressionFactory().
+                                    createMethodExpression(context.getELContext(),
+                                            attributeExpressionString, Void.TYPE, 
+                                            new Class[]{ValueChangeEvent.class});
 
-                                ((EditableValueHolder)innerComponent).addValueChangeListener(
-                                        new MethodExpressionValueChangeListener(methodExpression));
-                            }
+                            ((EditableValueHolder)innerComponent).addValueChangeListener(
+                                    new MethodExpressionValueChangeListener(methodExpression));
                         }
                     }
-                    else
-                    {
-                        // composite:attribute targets property only has sense for action,
actionListener,
-                        // validator or valueChangeListener. This means we have to retarget
the method expression
-                        // to the topLevelComponent.
-                        methodSignature = methodSignature.trim();
-                        methodExpression = context.getApplication().getExpressionFactory().
-                        createMethodExpression(context.getELContext(),
-                                attributeExpressionString, _getReturnType(methodSignature),

-                                _getParameters(methodSignature));
-                        topLevelComponent.getAttributes().put(attributeName, methodExpression);
-                    }
-                    
-                    // We need to remove the previous ValueExpression, to prevent some possible
-                    // confusion when the same value is retrieved from the attribute map.
-                    topLevelComponent.setValueExpression(attributeName, null);
                 }
+                else
+                {
+                    // composite:attribute targets property only has sense for action, actionListener,
+                    // validator or valueChangeListener. This means we have to retarget the
method expression
+                    // to the topLevelComponent.
+                    methodSignature = methodSignature.trim();
+                    methodExpression = context.getApplication().getExpressionFactory().
+                    createMethodExpression(context.getELContext(),
+                            attributeExpressionString, _getReturnType(methodSignature), 
+                            _getParameters(methodSignature));
+                    topLevelComponent.getAttributes().put(attributeName, methodExpression);
+                }
+                
+                // We need to remove the previous ValueExpression, to prevent some possible
+                // confusion when the same value is retrieved from the attribute map.
+                topLevelComponent.setValueExpression(attributeName, null);
             }
         }
     }



Mime
View raw message