You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2011/10/31 20:03:30 UTC

svn commit: r1195618 - in /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces: application/ config/annotation/ view/facelets/ view/facelets/impl/ view/facelets/tag/ view/facelets/tag/jsf/

Author: lu4242
Date: Mon Oct 31 19:03:29 2011
New Revision: 1195618

URL: http://svn.apache.org/viewvc?rev=1195618&view=rev
Log:
MYFACES-3368 enable 'standard' checkstyle checks in myfaces-core

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletCompositionContext.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCompositionContextImpl.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ValidatorTagHandlerDelegate.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java?rev=1195618&r1=1195617&r2=1195618&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java Mon Oct 31 19:03:29 2011
@@ -653,65 +653,67 @@ public class NavigationHandlerImpl
 
         if (_navigationCases == null || runtimeConfig.isNavigationRulesChanged())
         {
-            synchronized (this)
-            {
-                if (_navigationCases == null || runtimeConfig.isNavigationRulesChanged())
-                {
-                    Collection<? extends NavigationRule> rules = runtimeConfig.getNavigationRules();
-                    int rulesSize = rules.size();
-
-                    Map<String, Set<NavigationCase>> cases = new HashMap<String, Set<NavigationCase>>(
-                            HashMapUtils.calcCapacity(rulesSize));
+            calculateNavigationCases(facesContext, runtimeConfig);
+        }
+        return _navigationCases;
+    }
+    
+    private synchronized void calculateNavigationCases(FacesContext facesContext, RuntimeConfig runtimeConfig)
+    {
+        if (_navigationCases == null || runtimeConfig.isNavigationRulesChanged())
+        {
+            Collection<? extends NavigationRule> rules = runtimeConfig.getNavigationRules();
+            int rulesSize = rules.size();
 
-                    List<String> wildcardKeys = new ArrayList<String>();
+            Map<String, Set<NavigationCase>> cases = new HashMap<String, Set<NavigationCase>>(
+                    HashMapUtils.calcCapacity(rulesSize));
 
-                    for (NavigationRule rule : rules)
-                    {
-                        String fromViewId = rule.getFromViewId();
+            List<String> wildcardKeys = new ArrayList<String>();
 
-                        //specification 7.4.2 footnote 4 - missing fromViewId is allowed:
-                        if (fromViewId == null)
-                        {
-                            fromViewId = ASTERISK;
-                        }
-                        else
-                        {
-                            fromViewId = fromViewId.trim();
-                        }
-
-                        Set<NavigationCase> set = cases.get(fromViewId);
-                        if (set == null)
-                        {
-                            set = new HashSet<NavigationCase>(convertNavigationCasesToAPI(rule));
-                            cases.put(fromViewId, set);
-                            if (fromViewId.endsWith(ASTERISK))
-                            {
-                                wildcardKeys.add(fromViewId);
-                            }
-                        }
-                        else
-                        {
-                            set.addAll(convertNavigationCasesToAPI(rule));
-                        }
-                    }
+            for (NavigationRule rule : rules)
+            {
+                String fromViewId = rule.getFromViewId();
 
-                    Collections.sort(wildcardKeys, new KeyComparator());
+                //specification 7.4.2 footnote 4 - missing fromViewId is allowed:
+                if (fromViewId == null)
+                {
+                    fromViewId = ASTERISK;
+                }
+                else
+                {
+                    fromViewId = fromViewId.trim();
+                }
 
-                    synchronized (cases)
+                Set<NavigationCase> set = cases.get(fromViewId);
+                if (set == null)
+                {
+                    set = new HashSet<NavigationCase>(convertNavigationCasesToAPI(rule));
+                    cases.put(fromViewId, set);
+                    if (fromViewId.endsWith(ASTERISK))
                     {
-                        // We do not really need this sychronization at all, but this
-                        // gives us the peace of mind that some good optimizing compiler
-                        // will not rearrange the execution of the assignment to an
-                        // earlier time, before all init code completes
-                        _navigationCases = cases;
-                        _wildcardKeys = wildcardKeys;
-
-                        runtimeConfig.setNavigationRulesChanged(false);
+                        wildcardKeys.add(fromViewId);
                     }
                 }
+                else
+                {
+                    set.addAll(convertNavigationCasesToAPI(rule));
+                }
+            }
+
+            Collections.sort(wildcardKeys, new KeyComparator());
+
+            synchronized (cases)
+            {
+                // We do not really need this sychronization at all, but this
+                // gives us the peace of mind that some good optimizing compiler
+                // will not rearrange the execution of the assignment to an
+                // earlier time, before all init code completes
+                _navigationCases = cases;
+                _wildcardKeys = wildcardKeys;
+
+                runtimeConfig.setNavigationRulesChanged(false);
             }
         }
-        return _navigationCases;
     }
 
     private static final class KeyComparator implements Comparator<String>

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java?rev=1195618&r1=1195617&r2=1195618&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java Mon Oct 31 19:03:29 2011
@@ -77,11 +77,6 @@ public class AnnotationConfigurator
     //private static final Log log = LogFactory.getLog(AnnotationConfigurator.class);
     private static final Logger log = Logger.getLogger(AnnotationConfigurator.class.getName());
 
-    /**
-     * <p>The render kit factory for this application.</p>
-     */
-    private RenderKitFactory rkFactory = null;
-
     public AnnotationConfigurator()
     {
     }
@@ -98,6 +93,12 @@ public class AnnotationConfigurator
         return null;
     }
 
+    /**
+     * TODO: Implement strategy pattern over this method.
+     * 
+     * @param map
+     * @return
+     */
     protected FacesConfig createFacesConfig(Map<Class<? extends Annotation>, Set<Class<?>>> map)
     {
         FacesConfig facesConfig = new FacesConfig();
@@ -240,247 +241,267 @@ public class AnnotationConfigurator
         classes = map.get(ManagedBean.class);
         if (classes != null && !classes.isEmpty())
         {
-            for (Class<?> clazz : classes)
-            {
-                javax.faces.bean.ManagedBean bean =
-                        (javax.faces.bean.ManagedBean) clazz.getAnnotation(javax.faces.bean.ManagedBean.class);
+            handleManagedBean(facesConfig, classes);
+        }
 
-                if (bean != null)
-                {
-                    if (log.isLoggable(Level.FINE))
-                    {
-                        log.fine("Class '" + clazz.getName() + "' has an @ManagedBean annotation");
-                    }
+        classes = map.get(NamedEvent.class);
+        if (classes != null && !classes.isEmpty())
+        {
+            handleNamedEvent(facesConfig, classes);
+        }
 
-                    org.apache.myfaces.config.impl.digester.elements.ManagedBean mbc =
-                            new org.apache.myfaces.config.impl.digester.elements.ManagedBean();
-                    String beanName = bean.name();
+        classes = map.get(FacesBehavior.class);
+        if (classes != null && !classes.isEmpty())
+        {
+            handleFacesBehavior(facesConfig, classes);
+        }
 
-                    if ((beanName == null) || beanName.equals(""))
-                    {
-                        int index;
+        classes = map.get(FacesBehaviorRenderer.class);
+        if (classes != null && !classes.isEmpty())
+        {
+            handleFacesBehaviorRenderer(facesConfig, classes);
+        }
+        return facesConfig;
+    }
+    
+    private void handleManagedBean(FacesConfig facesConfig, Set<Class<?>> classes)
+    {
+        for (Class<?> clazz : classes)
+        {
+            javax.faces.bean.ManagedBean bean =
+                    (javax.faces.bean.ManagedBean) clazz.getAnnotation(javax.faces.bean.ManagedBean.class);
 
-                        // Missing name attribute algorithm: take the unqualified name and make the
-                        // first character lowercase.
+            if (bean != null)
+            {
+                if (log.isLoggable(Level.FINE))
+                {
+                    log.fine("Class '" + clazz.getName() + "' has an @ManagedBean annotation");
+                }
 
-                        beanName = clazz.getName();
-                        index = beanName.lastIndexOf(".");
+                org.apache.myfaces.config.impl.digester.elements.ManagedBean mbc =
+                        new org.apache.myfaces.config.impl.digester.elements.ManagedBean();
+                String beanName = bean.name();
 
-                        if (index != -1)
-                        {
-                            beanName = beanName.substring(index + 1);
-                        }
+                if ((beanName == null) || beanName.equals(""))
+                {
+                    int index;
+
+                    // Missing name attribute algorithm: take the unqualified name and make the
+                    // first character lowercase.
+
+                    beanName = clazz.getName();
+                    index = beanName.lastIndexOf(".");
 
-                        beanName = Character.toLowerCase(beanName.charAt(0)) +
-                                beanName.substring(1);
+                    if (index != -1)
+                    {
+                        beanName = beanName.substring(index + 1);
                     }
 
-                    mbc.setName(beanName);
-                    mbc.setEager(Boolean.toString(bean.eager()));
-                    mbc.setBeanClass(clazz.getName());
+                    beanName = Character.toLowerCase(beanName.charAt(0)) +
+                            beanName.substring(1);
+                }
+
+                mbc.setName(beanName);
+                mbc.setEager(Boolean.toString(bean.eager()));
+                mbc.setBeanClass(clazz.getName());
 
-                    ApplicationScoped appScoped = (ApplicationScoped) clazz.getAnnotation(ApplicationScoped.class);
-                    if (appScoped != null)
+                ApplicationScoped appScoped = (ApplicationScoped) clazz.getAnnotation(ApplicationScoped.class);
+                if (appScoped != null)
+                {
+                    mbc.setScope("application");
+                }
+
+                else
+                {
+                    NoneScoped noneScoped = (NoneScoped) clazz.getAnnotation(NoneScoped.class);
+                    if (noneScoped != null)
                     {
-                        mbc.setScope("application");
+                        mbc.setScope("none");
                     }
 
                     else
                     {
-                        NoneScoped noneScoped = (NoneScoped) clazz.getAnnotation(NoneScoped.class);
-                        if (noneScoped != null)
+                        RequestScoped requestScoped = (RequestScoped) clazz.getAnnotation(RequestScoped.class);
+                        if (requestScoped != null)
                         {
-                            mbc.setScope("none");
+                            mbc.setScope("request");
                         }
 
                         else
                         {
-                            RequestScoped requestScoped = (RequestScoped) clazz.getAnnotation(RequestScoped.class);
-                            if (requestScoped != null)
+                            SessionScoped sessionScoped = (SessionScoped) clazz.getAnnotation(SessionScoped.class);
+                            if (sessionScoped != null)
                             {
-                                mbc.setScope("request");
+                                mbc.setScope("session");
                             }
 
                             else
                             {
-                                SessionScoped sessionScoped = (SessionScoped) clazz.getAnnotation(SessionScoped.class);
-                                if (sessionScoped != null)
+                                ViewScoped viewScoped = (ViewScoped) clazz.getAnnotation(ViewScoped.class);
+                                if (viewScoped != null)
                                 {
-                                    mbc.setScope("session");
+                                    mbc.setScope("view");
                                 }
 
                                 else
                                 {
-                                    ViewScoped viewScoped = (ViewScoped) clazz.getAnnotation(ViewScoped.class);
-                                    if (viewScoped != null)
+                                    CustomScoped customScoped
+                                            = (CustomScoped) clazz.getAnnotation(CustomScoped.class);
+                                    if (customScoped != null)
                                     {
-                                        mbc.setScope("view");
+                                        mbc.setScope(customScoped.value());
                                     }
 
                                     else
                                     {
-                                        CustomScoped customScoped
-                                                = (CustomScoped) clazz.getAnnotation(CustomScoped.class);
-                                        if (customScoped != null)
-                                        {
-                                            mbc.setScope(customScoped.value());
-                                        }
-
-                                        else
-                                        {
-                                            // No scope annotation means default of "request".
+                                        // No scope annotation means default of "request".
 
-                                            mbc.setScope("request");
-                                        }
+                                        mbc.setScope("request");
                                     }
                                 }
                             }
                         }
                     }
+                }
 
-                    Field[] fields = fields(clazz);
-                    for (Field field : fields)
+                Field[] fields = fields(clazz);
+                for (Field field : fields)
+                {
+                    if (log.isLoggable(Level.FINEST))
+                    {
+                        log.finest("  Scanning field '" + field.getName() + "'");
+                    }
+                    javax.faces.bean.ManagedProperty property = (javax.faces.bean.ManagedProperty) field
+                            .getAnnotation(javax.faces.bean.ManagedProperty.class);
+                    if (property != null)
                     {
-                        if (log.isLoggable(Level.FINEST))
+                        if (log.isLoggable(Level.FINE))
                         {
-                            log.finest("  Scanning field '" + field.getName() + "'");
+                            log.fine("  Field '" + field.getName()
+                                    + "' has a @ManagedProperty annotation");
                         }
-                        javax.faces.bean.ManagedProperty property = (javax.faces.bean.ManagedProperty) field
-                                .getAnnotation(javax.faces.bean.ManagedProperty.class);
-                        if (property != null)
+                        org.apache.myfaces.config.impl.digester.elements.ManagedProperty mpc =
+                                new org.apache.myfaces.config.impl.digester.elements.ManagedProperty();
+                        String name = property.name();
+                        if ((name == null) || "".equals(name))
                         {
-                            if (log.isLoggable(Level.FINE))
-                            {
-                                log.fine("  Field '" + field.getName()
-                                        + "' has a @ManagedProperty annotation");
-                            }
-                            org.apache.myfaces.config.impl.digester.elements.ManagedProperty mpc =
-                                    new org.apache.myfaces.config.impl.digester.elements.ManagedProperty();
-                            String name = property.name();
-                            if ((name == null) || "".equals(name))
-                            {
-                                name = field.getName();
-                            }
-                            mpc.setPropertyName(name);
-                            mpc.setPropertyClass(field.getType().getName()); // FIXME - primitives, arrays, etc.
-                            mpc.setValue(property.value());
-                            mbc.addProperty(mpc);
-                            continue;
+                            name = field.getName();
                         }
+                        mpc.setPropertyName(name);
+                        mpc.setPropertyClass(field.getType().getName()); // FIXME - primitives, arrays, etc.
+                        mpc.setValue(property.value());
+                        mbc.addProperty(mpc);
+                        continue;
                     }
-                    facesConfig.addManagedBean(mbc);
                 }
+                facesConfig.addManagedBean(mbc);
             }
         }
-
-        classes = map.get(NamedEvent.class);
-        if (classes != null && !classes.isEmpty())
+    }
+    
+    private void handleNamedEvent(FacesConfig facesConfig, Set<Class<?>> classes)
+    {
+        for (Class<?> clazz : classes)
         {
-            for (Class<?> clazz : classes)
+            NamedEvent namedEvent = (NamedEvent) clazz.getAnnotation(NamedEvent.class);
+
+            if (namedEvent != null)
             {
-                NamedEvent namedEvent = (NamedEvent) clazz.getAnnotation(NamedEvent.class);
+                // Can only apply @NamedEvent to ComponentSystemEvent subclasses.
 
-                if (namedEvent != null)
+                if (!ComponentSystemEvent.class.isAssignableFrom(clazz))
                 {
-                    // Can only apply @NamedEvent to ComponentSystemEvent subclasses.
+                    // Just log this.  We'll catch it later in the runtime.
 
-                    if (!ComponentSystemEvent.class.isAssignableFrom(clazz))
+                    if (log.isLoggable(Level.WARNING))
                     {
-                        // Just log this.  We'll catch it later in the runtime.
-
-                        if (log.isLoggable(Level.WARNING))
-                        {
-                            log.warning(clazz.getName() + " is annotated with @javax.faces.event.NamedEvent, but does "
-                                        + "not extend javax.faces.event.ComponentSystemEvent");
-                        }
+                        log.warning(clazz.getName() + " is annotated with @javax.faces.event.NamedEvent, but does "
+                                    + "not extend javax.faces.event.ComponentSystemEvent");
                     }
-                    // Have to register @NamedEvent annotations with the NamedEventManager class since
-                    // we need to get access to this info later and can't from the dispenser (it's not a
-                    // singleton).
-                    org.apache.myfaces.config.impl.digester.elements.NamedEvent namedEventConfig =
-                            new org.apache.myfaces.config.impl.digester.elements.NamedEvent();
-                    namedEventConfig.setEventClass(clazz.getName());
-                    namedEventConfig.setShortName(namedEvent.shortName());
-                    facesConfig.addNamedEvent(namedEventConfig);
                 }
+                // Have to register @NamedEvent annotations with the NamedEventManager class since
+                // we need to get access to this info later and can't from the dispenser (it's not a
+                // singleton).
+                org.apache.myfaces.config.impl.digester.elements.NamedEvent namedEventConfig =
+                        new org.apache.myfaces.config.impl.digester.elements.NamedEvent();
+                namedEventConfig.setEventClass(clazz.getName());
+                namedEventConfig.setShortName(namedEvent.shortName());
+                facesConfig.addNamedEvent(namedEventConfig);
             }
         }
+    }
 
-        classes = map.get(FacesBehavior.class);
-        if (classes != null && !classes.isEmpty())
+    private void handleFacesBehavior(FacesConfig facesConfig, Set<Class<?>> classes)
+    {
+        for (Class<?> clazz : classes)
         {
-            for (Class<?> clazz : classes)
+            FacesBehavior facesBehavior = (FacesBehavior) clazz.getAnnotation(FacesBehavior.class);
+
+            if (facesBehavior != null)
             {
-                FacesBehavior facesBehavior = (FacesBehavior) clazz.getAnnotation(FacesBehavior.class);
+                // Can only apply @FacesBehavior to Behavior implementors.
 
-                if (facesBehavior != null)
+                if (!javax.faces.component.behavior.Behavior.class.isAssignableFrom(clazz))
                 {
-                    // Can only apply @FacesBehavior to Behavior implementors.
+                    // Just log this.  We'll catch it later in the runtime.
 
-                    if (!javax.faces.component.behavior.Behavior.class.isAssignableFrom(clazz))
+                    if (log.isLoggable(Level.WARNING))
                     {
-                        // Just log this.  We'll catch it later in the runtime.
-
-                        if (log.isLoggable(Level.WARNING))
-                        {
-                            log.warning(clazz.getName()
-                                        + " is annotated with @javax.faces.component.behavior.FacesBehavior, "
-                                        + "but does not implement javax.faces.component.behavior.Behavior");
-                        }
-                    }
-
-                    if (log.isLoggable(Level.FINEST))
-                    {
-                        log.finest("addBehavior(" + facesBehavior.value() + ", " + clazz.getName() + ")");
+                        log.warning(clazz.getName()
+                                    + " is annotated with @javax.faces.component.behavior.FacesBehavior, "
+                                    + "but does not implement javax.faces.component.behavior.Behavior");
                     }
+                }
 
-                    Behavior behavior = new Behavior();
-                    behavior.setBehaviorId(facesBehavior.value());
-                    behavior.setBehaviorClass(clazz.getName());
-                    facesConfig.addBehavior(behavior);
+                if (log.isLoggable(Level.FINEST))
+                {
+                    log.finest("addBehavior(" + facesBehavior.value() + ", " + clazz.getName() + ")");
                 }
 
+                Behavior behavior = new Behavior();
+                behavior.setBehaviorId(facesBehavior.value());
+                behavior.setBehaviorClass(clazz.getName());
+                facesConfig.addBehavior(behavior);
             }
-        }
 
-        classes = map.get(FacesBehaviorRenderer.class);
-        if (classes != null && !classes.isEmpty())
+        }
+    }
+    
+    private void handleFacesBehaviorRenderer(FacesConfig facesConfig, Set<Class<?>> classes)
+    {
+        for (Class<?> clazz : classes)
         {
-            for (Class<?> clazz : classes)
+            FacesBehaviorRenderer facesBehaviorRenderer
+                    = (FacesBehaviorRenderer) clazz.getAnnotation(FacesBehaviorRenderer.class);
+
+            if (facesBehaviorRenderer != null)
             {
-                FacesBehaviorRenderer facesBehaviorRenderer
-                        = (FacesBehaviorRenderer) clazz.getAnnotation(FacesBehaviorRenderer.class);
+                String renderKitId = facesBehaviorRenderer.renderKitId();
+                //RenderKit renderKit;
 
-                if (facesBehaviorRenderer != null)
+                if (log.isLoggable(Level.FINEST))
                 {
-                    String renderKitId = facesBehaviorRenderer.renderKitId();
-                    //RenderKit renderKit;
-
-                    if (log.isLoggable(Level.FINEST))
-                    {
-                        log.finest("addClientBehaviorRenderer(" + renderKitId + ", "
-                                   + facesBehaviorRenderer.rendererType() + ", "
-                                   + clazz.getName() + ")");
-                    }
-
-                    org.apache.myfaces.config.impl.digester.elements.RenderKit renderKit =
-                            (org.apache.myfaces.config.impl.digester.elements.RenderKit)
-                                    facesConfig.getRenderKit(renderKitId);
-                    if (renderKit == null)
-                    {
-                        renderKit = new org.apache.myfaces.config.impl.digester.elements.RenderKit();
-                        facesConfig.addRenderKit(renderKit);
-                    }
+                    log.finest("addClientBehaviorRenderer(" + renderKitId + ", "
+                               + facesBehaviorRenderer.rendererType() + ", "
+                               + clazz.getName() + ")");
+                }
 
-                    org.apache.myfaces.config.impl.digester.elements.ClientBehaviorRenderer cbr =
-                            new org.apache.myfaces.config.impl.digester.elements.ClientBehaviorRenderer();
-                    cbr.setRendererType(facesBehaviorRenderer.rendererType());
-                    cbr.setRendererClass(clazz.getName());
-                    renderKit.addClientBehaviorRenderer(cbr);
+                org.apache.myfaces.config.impl.digester.elements.RenderKit renderKit =
+                        (org.apache.myfaces.config.impl.digester.elements.RenderKit)
+                                facesConfig.getRenderKit(renderKitId);
+                if (renderKit == null)
+                {
+                    renderKit = new org.apache.myfaces.config.impl.digester.elements.RenderKit();
+                    facesConfig.addRenderKit(renderKit);
                 }
+
+                org.apache.myfaces.config.impl.digester.elements.ClientBehaviorRenderer cbr =
+                        new org.apache.myfaces.config.impl.digester.elements.ClientBehaviorRenderer();
+                cbr.setRendererType(facesBehaviorRenderer.rendererType());
+                cbr.setRendererClass(clazz.getName());
+                renderKit.addClientBehaviorRenderer(cbr);
             }
         }
-        return facesConfig;
     }
 
     /**

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletCompositionContext.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletCompositionContext.java?rev=1195618&r1=1195617&r2=1195618&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletCompositionContext.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletCompositionContext.java Mon Oct 31 19:03:29 2011
@@ -208,7 +208,8 @@ abstract public class FaceletComposition
      * @param attachedObjectHandler
      * @since 2.0.10
      */
-    public abstract void pushEnclosingValidatorIdToStack(String validatorId, EditableValueHolderAttachedObjectHandler attachedObjectHandler);
+    public abstract void pushEnclosingValidatorIdToStack(String validatorId, 
+            EditableValueHolderAttachedObjectHandler attachedObjectHandler);
 
     /**
      * Gets all validationIds with its associated EditableValueHolderAttachedObjectHandler from the stack.
@@ -216,7 +217,8 @@ abstract public class FaceletComposition
      * @return
      * @since 2.0.10
      */
-    public abstract Iterator<Map.Entry<String, EditableValueHolderAttachedObjectHandler>> getEnclosingValidatorIdsAndHandlers();
+    public abstract Iterator<Map.Entry<String, EditableValueHolderAttachedObjectHandler>> 
+        getEnclosingValidatorIdsAndHandlers();
     
     /**
      * 

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=1195618&r1=1195617&r2=1195618&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 Oct 31 19:03:29 2011
@@ -1120,8 +1120,6 @@ public class FaceletViewDeclarationLangu
 
                     String[] targetsArray = StringUtils.splitShortString(targets, ' ');
                     String attributeExpressionString = attributeNameValueExpression.getExpressionString();
-                    MethodExpression methodExpression = null;
-                    MethodExpression methodExpression2 = null;
 
                     //Check if the stored valueExpression is a ccRedirection, to handle it properly later.
                     boolean ccAttrMeRedirection =
@@ -1139,85 +1137,35 @@ public class FaceletViewDeclarationLangu
                         // expression is used (for example when a nested #{cc.attrs.xxx} is used).
                         if ("action".equals(targetAttributeName))
                         {
-                            // target is ActionSource2
-                            methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
-                                    createMethodExpression(elContext,
-                                            attributeExpressionString, null,
-                                            EMPTY_CLASS_ARRAY), attributeNameValueExpression);
-
-                            //Store the method expression to the topLevelComponent to allow reference it through EL
-                            if (!ccAttrMeRedirection)
-                            {
-                                //Replace it with a method expression
-                                topLevelComponent.getAttributes().put(attributeName, methodExpression);
-                            }
-                            // Otherwise keep the current ValueExpression,
-                            // because it will be used chain other value expressions
+                            applyActionMethodExpressionEL(context, elContext,
+                                    topLevelComponent, attributeName,
+                                    attributeExpressionString, attributeNameValueExpression,
+                                    ccAttrMeRedirection);
                         }
                         else if ("actionListener".equals(targetAttributeName))
                         {
-                            // target is ActionSource2
-                            methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
-                                    createMethodExpression(elContext,
-                                            attributeExpressionString, Void.TYPE, ACTION_LISTENER_SIGNATURE),
-                                            attributeNameValueExpression);
-
-                            methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
-                                    createMethodExpression(elContext,
-                                            attributeExpressionString, Void.TYPE, EMPTY_CLASS_ARRAY),
-                                            attributeNameValueExpression);
-
-                            //Store the method expression to the topLevelComponent to allow reference it through EL
-                            if (!ccAttrMeRedirection)
-                            {
-                                //Replace it with a method expression
-                                topLevelComponent.getAttributes().put(attributeName,
-                                        new MethodExpressionMethodExpression(methodExpression, methodExpression2));
-                            }
-                            // Otherwise keep the current ValueExpression,
-                            // because it will be used chain other value expressions
+                            applyActionListenerMethodExpressionEL(context, elContext,
+                                    topLevelComponent, attributeName, 
+                                    attributeExpressionString, attributeNameValueExpression, 
+                                    ccAttrMeRedirection);
                         }
                         else if ("validator".equals(targetAttributeName))
                         {
-                            // target is EditableValueHolder
-                            methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
-                                    createMethodExpression(elContext,
-                                            attributeExpressionString, Void.TYPE,
-                                            VALIDATOR_SIGNATURE), attributeNameValueExpression);
-
-                            //Store the method expression to the topLevelComponent to allow reference it through EL
-                            if (!ccAttrMeRedirection)
-                            {
-                                //Replace it with a method expression
-                                topLevelComponent.getAttributes().put(attributeName, methodExpression);
-                            }
-                            // Otherwise keep the current ValueExpression,
-                            // because it will be used chain other value expressions
+                            applyValidatorMethodExpressionEL(context, elContext,
+                                    topLevelComponent, attributeName,
+                                    attributeExpressionString, attributeNameValueExpression, 
+                                    ccAttrMeRedirection);
                         }
                         else if ("valueChangeListener".equals(targetAttributeName))
                         {
-                            // target is EditableValueHolder
-                            methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
-                                    createMethodExpression(elContext,
-                                            attributeExpressionString, Void.TYPE,
-                                            VALUE_CHANGE_LISTENER_SIGNATURE), attributeNameValueExpression);
-
-                            methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
-                                    createMethodExpression(elContext,
-                                            attributeExpressionString, Void.TYPE,
-                                            EMPTY_CLASS_ARRAY), attributeNameValueExpression);
-
-                            //Store the method expression to the topLevelComponent to allow reference it through EL
-                            if (!ccAttrMeRedirection)
-                            {
-                                //Replace it with a method expression
-                                topLevelComponent.getAttributes().put(attributeName,
-                                        new MethodExpressionMethodExpression(methodExpression, methodExpression2));
-                            }
-                            // Otherwise keep the current ValueExpression, because it will be used chain other value expressions
+                            applyValueChangeListenerMethodExpressionEL(context, elContext,
+                                    topLevelComponent, attributeName, 
+                                    attributeExpressionString, attributeNameValueExpression,
+                                    ccAttrMeRedirection);
                         }
 
-                        UIComponent topLevelComponentBase = topLevelComponent.getFacet(UIComponent.COMPOSITE_FACET_NAME);
+                        UIComponent topLevelComponentBase = 
+                            topLevelComponent.getFacet(UIComponent.COMPOSITE_FACET_NAME);
 
                         for (String target : targetsArray)
                         {
@@ -1242,123 +1190,42 @@ public class FaceletViewDeclarationLangu
                             {
                                 if ("action".equals(targetAttributeName))
                                 {
-                                    // target is ActionSource2
-                                    methodExpression
-                                            = reWrapMethodExpression(context.getApplication().getExpressionFactory().
-                                            createMethodExpression(elContext,
-                                                    attributeExpressionString, null, EMPTY_CLASS_ARRAY),
-                                                    attributeNameValueExpression);
-
-                                    // If it is a redirection, a wrapper is used to
-                                    // locate the right instance and call it properly.
-                                    if (ccAttrMeRedirection)
-                                    {
-                                        ((ActionSource2) innerComponent).setActionExpression(
-                                                new ValueExpressionMethodExpression(attributeNameValueExpression));
-                                    }
-                                    else
-                                    {
-                                        ((ActionSource2) innerComponent).setActionExpression(methodExpression);
-                                    }
+                                    applyActionMethodExpressionTarget(context, mctx, elContext,
+                                            topLevelComponentBase, innerComponent, 
+                                            attributeName, targetAttributeName, 
+                                            attributeExpressionString, attributeNameValueExpression, 
+                                            ccAttrMeRedirection);
                                 }
                                 else if ("actionListener".equals(targetAttributeName))
                                 {
-                                    //First try to remove any prevous target if any
-                                    ActionListener o = (ActionListener)
-                                            mctx.removeMethodExpressionTargeted(innerComponent, targetAttributeName);
-                                    if (o != null)
-                                    {
-                                        ((ActionSource2) innerComponent).removeActionListener(o);
-                                    }
-
-                                    // target is ActionSource2
-                                    ActionListener actionListener = null;
-                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
-                                    if (ccAttrMeRedirection)
-                                    {
-                                        actionListener = new RedirectMethodExpressionValueExpressionActionListener(
-                                                                     attributeNameValueExpression);
-                                    }
-                                    else
-                                    {
-                                        methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
-                                                createMethodExpression(elContext,
-                                                   attributeExpressionString, Void.TYPE, ACTION_LISTENER_SIGNATURE), attributeNameValueExpression);
-
-                                        methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
-                                                createMethodExpression(elContext,
-                                                        attributeExpressionString, Void.TYPE, EMPTY_CLASS_ARRAY), attributeNameValueExpression);
-
-                                        actionListener = new MethodExpressionActionListener(methodExpression, methodExpression2);
-                                    }
-                                    ((ActionSource2) innerComponent).addActionListener(actionListener);
-                                    mctx.addMethodExpressionTargeted(innerComponent, targetAttributeName, actionListener);
+                                    applyActionListenerMethodExpressionTarget(context, mctx, elContext, 
+                                            topLevelComponentBase, innerComponent, 
+                                            attributeName, targetAttributeName, 
+                                            attributeExpressionString, attributeNameValueExpression, 
+                                            ccAttrMeRedirection);
                                 }
                                 else if ("validator".equals(targetAttributeName))
                                 {
-                                    //First try to remove any prevous target if any
-                                    Validator o = (Validator) mctx.removeMethodExpressionTargeted(innerComponent, targetAttributeName);
-                                    if (o != null)
-                                    {
-                                        ((EditableValueHolder) innerComponent).removeValidator(o);
-                                    }
-
-                                    // target is EditableValueHolder
-                                    Validator validator = null;
-                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
-                                    if (ccAttrMeRedirection)
-                                    {
-                                        validator = new RedirectMethodExpressionValueExpressionValidator(attributeNameValueExpression);
-                                    }
-                                    else
-                                    {
-                                        methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
-                                                createMethodExpression(elContext,
-                                                        attributeExpressionString, Void.TYPE,
-                                                        VALIDATOR_SIGNATURE), attributeNameValueExpression);
-
-                                        validator = new MethodExpressionValidator(methodExpression);
-                                    }
-                                    ((EditableValueHolder) innerComponent).addValidator(validator);
-                                    mctx.addMethodExpressionTargeted(innerComponent, targetAttributeName, validator);
+                                    applyValidatorMethodExpressionTarget(context, mctx, elContext,
+                                            topLevelComponentBase, innerComponent, 
+                                            attributeName, targetAttributeName, 
+                                            attributeExpressionString, attributeNameValueExpression, 
+                                            ccAttrMeRedirection);
                                 }
                                 else if ("valueChangeListener".equals(targetAttributeName))
                                 {
-                                    ValueChangeListener o = (ValueChangeListener) mctx.removeMethodExpressionTargeted(innerComponent, targetAttributeName);
-                                    if (o != null)
-                                    {
-                                        ((EditableValueHolder) innerComponent).removeValueChangeListener(o);
-                                    }
-
-                                    // target is EditableValueHolder
-                                    ValueChangeListener valueChangeListener = null;
-                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
-                                    if (ccAttrMeRedirection)
-                                    {
-                                        valueChangeListener = new RedirectMethodExpressionValueExpressionValueChangeListener(attributeNameValueExpression);
-                                    }
-                                    else
-                                    {
-                                        methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
-                                                createMethodExpression(elContext,
-                                                        attributeExpressionString, Void.TYPE,
-                                                        VALUE_CHANGE_LISTENER_SIGNATURE), attributeNameValueExpression);
-
-                                        methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
-                                                createMethodExpression(elContext,
-                                                        attributeExpressionString, Void.TYPE,
-                                                        EMPTY_CLASS_ARRAY), attributeNameValueExpression);
-
-                                        valueChangeListener = new MethodExpressionValueChangeListener(methodExpression, methodExpression2);
-                                    }
-                                    ((EditableValueHolder) innerComponent).addValueChangeListener(valueChangeListener);
-                                    mctx.addMethodExpressionTargeted(innerComponent, targetAttributeName, valueChangeListener);
+                                    applyValueChangeListenerMethodExpressionTarget(context, mctx, elContext,
+                                            topLevelComponentBase, innerComponent, 
+                                            attributeName, targetAttributeName,
+                                            attributeExpressionString, attributeNameValueExpression,
+                                            ccAttrMeRedirection);
                                 }
                             }
                         }
                     }
                     else
                     {
+                        MethodExpression methodExpression = null;
                         // 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.
@@ -1373,49 +1240,9 @@ public class FaceletViewDeclarationLangu
 
                         methodExpression = reWrapMethodExpression(methodExpression, attributeNameValueExpression);
 
-                        UIComponent topLevelComponentBase = topLevelComponent.getFacet(UIComponent.COMPOSITE_FACET_NAME);
-
-                        for (String target : targetsArray)
-                        {
-                            UIComponent innerComponent = ComponentSupport.findComponentChildOrFacetFrom(context, topLevelComponentBase, target);
-
-                            if (innerComponent == null)
-                            {
-                                continue;
-                            }
-
-                            // If a component is found, that means the expression should be retarget to the
-                            // components related
-                            if (isCompositeComponentRetarget(context, innerComponent, targetAttributeName))
-                            {
-                                innerComponent.getAttributes().put(targetAttributeName, attributeNameValueExpression);
-
-                                mctx.clearMethodExpressionAttribute(innerComponent, targetAttributeName);
-
-                                retargetMethodExpressions(context, innerComponent);
-                            }
-                            else
-                            {
-                                //Put the retarget
-                                if (ccAttrMeRedirection)
-                                {
-                                    // Since we require here a method expression, it is necessary to wrap the ValueExpression
-                                    // into a MethodExpression that handles redirection.
-                                    innerComponent.getAttributes().put(targetAttributeName, new ValueExpressionMethodExpression(attributeNameValueExpression));
-                                }
-                                else
-                                {
-                                    innerComponent.getAttributes().put(targetAttributeName, methodExpression);
-                                }
-                            }
-                        }
-                        //Store the method expression to the topLevelComponent to allow reference it through EL
-                        if (!ccAttrMeRedirection)
-                        {
-                            //Replace it with a method expression
-                            topLevelComponent.getAttributes().put(attributeName, methodExpression);
-                        }
-                        // Othewise keep the current ValueExpression, because it will be used chain other value expressions
+                        applyMethodExpression(context, mctx, elContext, topLevelComponent, attributeName, 
+                                targetAttributeName, attributeNameValueExpression, methodExpression, 
+                                ccAttrMeRedirection, targetsArray);
                     }
                     mctx.markMethodExpressionAttribute(topLevelComponent, attributeName);
                 }
@@ -1426,6 +1253,326 @@ public class FaceletViewDeclarationLangu
             }
         }
     }
+    
+    private void applyActionMethodExpressionEL(FacesContext context, 
+                                               ELContext elContext, 
+                                               UIComponent topLevelComponent, 
+                                               String attributeName,
+                                               String attributeExpressionString, 
+                                               ValueExpression attributeNameValueExpression, 
+                                               boolean ccAttrMeRedirection)
+    {
+        // target is ActionSource2
+        MethodExpression methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
+                createMethodExpression(elContext,
+                        attributeExpressionString, null,
+                        EMPTY_CLASS_ARRAY), attributeNameValueExpression);
+
+        //Store the method expression to the topLevelComponent to allow reference it through EL
+        if (!ccAttrMeRedirection)
+        {
+            //Replace it with a method expression
+            topLevelComponent.getAttributes().put(attributeName, methodExpression);
+        }
+        // Otherwise keep the current ValueExpression,
+        // because it will be used chain other value expressions
+    }
+
+    private void applyActionListenerMethodExpressionEL(FacesContext context, 
+                                                       ELContext elContext, 
+                                                       UIComponent topLevelComponent, 
+                                                       String attributeName,
+                                                       String attributeExpressionString, 
+                                                       ValueExpression attributeNameValueExpression, 
+                                                       boolean ccAttrMeRedirection)
+    {
+        // target is ActionSource2
+        MethodExpression methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
+                createMethodExpression(elContext,
+                        attributeExpressionString, Void.TYPE, ACTION_LISTENER_SIGNATURE),
+                        attributeNameValueExpression);
+
+        MethodExpression methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
+                createMethodExpression(elContext,
+                        attributeExpressionString, Void.TYPE, EMPTY_CLASS_ARRAY),
+                        attributeNameValueExpression);
+
+        //Store the method expression to the topLevelComponent to allow reference it through EL
+        if (!ccAttrMeRedirection)
+        {
+            //Replace it with a method expression
+            topLevelComponent.getAttributes().put(attributeName,
+                    new MethodExpressionMethodExpression(methodExpression, methodExpression2));
+        }
+        // Otherwise keep the current ValueExpression,
+        // because it will be used chain other value expressions
+    }
+    
+    private void applyValidatorMethodExpressionEL(FacesContext context, 
+                                                  ELContext elContext, 
+                                                  UIComponent topLevelComponent, 
+                                                  String attributeName,
+                                                  String attributeExpressionString, 
+                                                  ValueExpression attributeNameValueExpression, 
+                                                  boolean ccAttrMeRedirection)
+    {
+        // target is EditableValueHolder
+        MethodExpression methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
+                createMethodExpression(elContext,
+                        attributeExpressionString, Void.TYPE,
+                        VALIDATOR_SIGNATURE), attributeNameValueExpression);
+
+        //Store the method expression to the topLevelComponent to allow reference it through EL
+        if (!ccAttrMeRedirection)
+        {
+            //Replace it with a method expression
+            topLevelComponent.getAttributes().put(attributeName, methodExpression);
+        }
+        // Otherwise keep the current ValueExpression,
+        // because it will be used chain other value expressions
+    }
+    
+    private void applyValueChangeListenerMethodExpressionEL(FacesContext context, 
+                                                            ELContext elContext, 
+                                                            UIComponent topLevelComponent, 
+                                                            String attributeName,
+                                                            String attributeExpressionString, 
+                                                            ValueExpression attributeNameValueExpression, 
+                                                            boolean ccAttrMeRedirection)
+    {
+        // target is EditableValueHolder
+        MethodExpression methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
+                createMethodExpression(elContext,
+                        attributeExpressionString, Void.TYPE,
+                        VALUE_CHANGE_LISTENER_SIGNATURE), attributeNameValueExpression);
+
+        MethodExpression methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
+                createMethodExpression(elContext,
+                        attributeExpressionString, Void.TYPE,
+                        EMPTY_CLASS_ARRAY), attributeNameValueExpression);
+
+        //Store the method expression to the topLevelComponent to allow reference it through EL
+        if (!ccAttrMeRedirection)
+        {
+            //Replace it with a method expression
+            topLevelComponent.getAttributes().put(attributeName,
+                    new MethodExpressionMethodExpression(methodExpression, methodExpression2));
+        }
+        // Otherwise keep the current ValueExpression, because it will be used chain other value expressions
+    }
+    
+    private void applyActionMethodExpressionTarget(FacesContext context, FaceletCompositionContext mctx,
+                                                   ELContext elContext, 
+                                                   UIComponent topLevelComponent,
+                                                   UIComponent innerComponent,
+                                                   String attributeName,
+                                                   String targetAttributeName,
+                                                   String attributeExpressionString,
+                                                   ValueExpression attributeNameValueExpression,
+                                                   boolean ccAttrMeRedirection)
+    {
+        // target is ActionSource2
+        MethodExpression methodExpression
+                = reWrapMethodExpression(context.getApplication().getExpressionFactory().
+                createMethodExpression(elContext,
+                        attributeExpressionString, null, EMPTY_CLASS_ARRAY),
+                        attributeNameValueExpression);
+
+        // If it is a redirection, a wrapper is used to
+        // locate the right instance and call it properly.
+        if (ccAttrMeRedirection)
+        {
+            ((ActionSource2) innerComponent).setActionExpression(
+                    new ValueExpressionMethodExpression(attributeNameValueExpression));
+        }
+        else
+        {
+            ((ActionSource2) innerComponent).setActionExpression(methodExpression);
+        }
+    }
+
+    private void applyActionListenerMethodExpressionTarget(FacesContext context, FaceletCompositionContext mctx,
+            ELContext elContext, 
+            UIComponent topLevelComponent,
+            UIComponent innerComponent,
+            String attributeName,
+            String targetAttributeName,
+            String attributeExpressionString,
+            ValueExpression attributeNameValueExpression,
+            boolean ccAttrMeRedirection)
+    {
+        //First try to remove any prevous target if any
+        ActionListener o = (ActionListener)
+                mctx.removeMethodExpressionTargeted(innerComponent, targetAttributeName);
+        if (o != null)
+        {
+            ((ActionSource2) innerComponent).removeActionListener(o);
+        }
+
+        // target is ActionSource2
+        ActionListener actionListener = null;
+        // If it is a redirection, a wrapper is used to locate the right instance and call
+        //it properly.
+        if (ccAttrMeRedirection)
+        {
+            actionListener = new RedirectMethodExpressionValueExpressionActionListener(
+                                         attributeNameValueExpression);
+        }
+        else
+        {
+            MethodExpression methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
+                    createMethodExpression(elContext,
+                       attributeExpressionString, Void.TYPE, ACTION_LISTENER_SIGNATURE), attributeNameValueExpression);
+
+            MethodExpression methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
+                    createMethodExpression(elContext,
+                            attributeExpressionString, Void.TYPE, EMPTY_CLASS_ARRAY), attributeNameValueExpression);
+
+            actionListener = new MethodExpressionActionListener(methodExpression, methodExpression2);
+        }
+        ((ActionSource2) innerComponent).addActionListener(actionListener);
+        mctx.addMethodExpressionTargeted(innerComponent, targetAttributeName, actionListener);
+    }
+    
+    private void applyValidatorMethodExpressionTarget(FacesContext context, FaceletCompositionContext mctx,
+            ELContext elContext, 
+            UIComponent topLevelComponent,
+            UIComponent innerComponent,
+            String attributeName,
+            String targetAttributeName,
+            String attributeExpressionString,
+            ValueExpression attributeNameValueExpression,
+            boolean ccAttrMeRedirection)
+    {
+        //First try to remove any prevous target if any
+        Validator o = (Validator) mctx.removeMethodExpressionTargeted(innerComponent, targetAttributeName);
+        if (o != null)
+        {
+            ((EditableValueHolder) innerComponent).removeValidator(o);
+        }
+
+        // target is EditableValueHolder
+        Validator validator = null;
+        // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
+        if (ccAttrMeRedirection)
+        {
+            validator = new RedirectMethodExpressionValueExpressionValidator(attributeNameValueExpression);
+        }
+        else
+        {
+            MethodExpression methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
+                    createMethodExpression(elContext,
+                            attributeExpressionString, Void.TYPE,
+                            VALIDATOR_SIGNATURE), attributeNameValueExpression);
+
+            validator = new MethodExpressionValidator(methodExpression);
+        }
+        ((EditableValueHolder) innerComponent).addValidator(validator);
+        mctx.addMethodExpressionTargeted(innerComponent, targetAttributeName, validator);
+    }
+    
+    private void applyValueChangeListenerMethodExpressionTarget(FacesContext context, FaceletCompositionContext mctx,
+            ELContext elContext, 
+            UIComponent topLevelComponent,
+            UIComponent innerComponent,
+            String attributeName,
+            String targetAttributeName,
+            String attributeExpressionString,
+            ValueExpression attributeNameValueExpression,
+            boolean ccAttrMeRedirection)
+    {
+        ValueChangeListener o = (ValueChangeListener) mctx.removeMethodExpressionTargeted(
+                innerComponent, targetAttributeName);
+        if (o != null)
+        {
+            ((EditableValueHolder) innerComponent).removeValueChangeListener(o);
+        }
+
+        // target is EditableValueHolder
+        ValueChangeListener valueChangeListener = null;
+        // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
+        if (ccAttrMeRedirection)
+        {
+            valueChangeListener = new RedirectMethodExpressionValueExpressionValueChangeListener(
+                    attributeNameValueExpression);
+        }
+        else
+        {
+            MethodExpression methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
+                    createMethodExpression(elContext,
+                            attributeExpressionString, Void.TYPE,
+                            VALUE_CHANGE_LISTENER_SIGNATURE), attributeNameValueExpression);
+
+            MethodExpression methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
+                    createMethodExpression(elContext,
+                            attributeExpressionString, Void.TYPE,
+                            EMPTY_CLASS_ARRAY), attributeNameValueExpression);
+
+            valueChangeListener = new MethodExpressionValueChangeListener(methodExpression, methodExpression2);
+        }
+        ((EditableValueHolder) innerComponent).addValueChangeListener(valueChangeListener);
+        mctx.addMethodExpressionTargeted(innerComponent, targetAttributeName, valueChangeListener);
+    }
+    
+    private void applyMethodExpression(FacesContext context, FaceletCompositionContext mctx,
+            ELContext elContext, 
+            UIComponent topLevelComponent,
+            String attributeName,
+            String targetAttributeName,
+            ValueExpression attributeNameValueExpression,
+            MethodExpression methodExpression,
+            boolean ccAttrMeRedirection,
+            String[] targetsArray)
+    {
+        UIComponent topLevelComponentBase = topLevelComponent.getFacet(
+                UIComponent.COMPOSITE_FACET_NAME);
+
+        for (String target : targetsArray)
+        {
+            UIComponent innerComponent = ComponentSupport.findComponentChildOrFacetFrom(context, 
+                    topLevelComponentBase, target);
+
+            if (innerComponent == null)
+            {
+                continue;
+            }
+
+            // If a component is found, that means the expression should be retarget to the
+            // components related
+            if (isCompositeComponentRetarget(context, innerComponent, targetAttributeName))
+            {
+                innerComponent.getAttributes().put(targetAttributeName, attributeNameValueExpression);
+
+                mctx.clearMethodExpressionAttribute(innerComponent, targetAttributeName);
+
+                retargetMethodExpressions(context, innerComponent);
+            }
+            else
+            {
+                //Put the retarget
+                if (ccAttrMeRedirection)
+                {
+                    // Since we require here a method expression, it is necessary to wrap 
+                    // the ValueExpression into a MethodExpression that handles redirection.
+                    innerComponent.getAttributes().put(targetAttributeName, 
+                            new ValueExpressionMethodExpression(attributeNameValueExpression));
+                }
+                else
+                {
+                    innerComponent.getAttributes().put(targetAttributeName, methodExpression);
+                }
+            }
+        }
+        //Store the method expression to the topLevelComponent to allow reference it through EL
+        if (!ccAttrMeRedirection)
+        {
+            //Replace it with a method expression
+            topLevelComponent.getAttributes().put(attributeName, methodExpression);
+        }
+        // Othewise keep the current ValueExpression, because it will be used chain other value 
+        // expressions
+    }
+
 
     private boolean isCompositeComponentRetarget(FacesContext context, UIComponent component, String attributeName)
     {
@@ -1464,7 +1611,8 @@ public class FaceletViewDeclarationLangu
                     }
 
                     String targetAttributeName = null;
-                    ValueExpression targetAttributeNameVE = (ValueExpression) propertyDescriptor.getValue("targetAttributeName");
+                    ValueExpression targetAttributeNameVE = (ValueExpression) 
+                        propertyDescriptor.getValue("targetAttributeName");
                     if (targetAttributeNameVE != null)
                     {
                         targetAttributeName = (String) targetAttributeNameVE.getValue(context.getELContext());
@@ -2341,7 +2489,8 @@ public class FaceletViewDeclarationLangu
         ExternalContext eContext = context.getExternalContext();
 
         // skip comments?
-        compiler.setTrimmingComments(WebConfigParamUtils.getBooleanInitParameter(eContext, PARAMS_SKIP_COMMENTS, false));
+        compiler.setTrimmingComments(WebConfigParamUtils.getBooleanInitParameter(
+                eContext, PARAMS_SKIP_COMMENTS, false));
     }
 
     /**

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java?rev=1195618&r1=1195617&r2=1195618&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java Mon Oct 31 19:03:29 2011
@@ -435,7 +435,8 @@ final class DefaultFaceletContext extend
         //    found = client.apply(this, parent, name);
         //}
         //return found;
-        return _isolatedTemplateContext.get(_currentTemplateContext).includeDefinition(this, this._facelet, parent, name);
+        return _isolatedTemplateContext.get(_currentTemplateContext).includeDefinition(
+                this, this._facelet, parent, name);
     }
 
     /*
@@ -533,7 +534,8 @@ final class DefaultFaceletContext extend
             _isolatedTemplateContext.add(new IsolatedTemplateContextImpl());
         }
         _currentTemplateContext++;
-        _isolatedTemplateContext.get(_currentTemplateContext).setCompositeComponentClient( new CompositeComponentTemplateManager(this._facelet, client));
+        _isolatedTemplateContext.get(_currentTemplateContext).setCompositeComponentClient(
+            new CompositeComponentTemplateManager(this._facelet, client));
     }
     
     @Override
@@ -557,7 +559,8 @@ final class DefaultFaceletContext extend
     public void pushCompositeComponentClient(final TemplateClient client)
     {
         TemplateContext itc = new TemplateContextImpl();
-        itc.setCompositeComponentClient(new CompositeComponentTemplateManager(this._facelet, client, getPageContext()));
+        itc.setCompositeComponentClient(
+                new CompositeComponentTemplateManager(this._facelet, client, getPageContext()));
         _isolatedTemplateContext.add(itc);
         _currentTemplateContext++;
         _defaultVarMapper.setTemplateContext(itc);
@@ -808,7 +811,8 @@ final class DefaultFaceletContext extend
     
     public boolean isAllowCacheELExpressions()
     {
-        return _isCacheELExpressions && getTemplateContext().isAllowCacheELExpressions() && getPageContext().isAllowCacheELExpressions();
+        return _isCacheELExpressions && getTemplateContext().isAllowCacheELExpressions() 
+                && getPageContext().isAllowCacheELExpressions();
     }
     
     public void beforeConstructELExpression()

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCompositionContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCompositionContextImpl.java?rev=1195618&r1=1195617&r2=1195618&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCompositionContextImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCompositionContextImpl.java Mon Oct 31 19:03:29 2011
@@ -313,7 +313,8 @@ public class FaceletCompositionContextIm
     {
         if (_enclosingValidatorIdsStack != null && !_enclosingValidatorIdsStack.isEmpty())
         {
-            return new KeyEntryIterator<String, EditableValueHolderAttachedObjectHandler>(_enclosingValidatorIdsStack.iterator()); 
+            return new KeyEntryIterator<String, EditableValueHolderAttachedObjectHandler>
+                (_enclosingValidatorIdsStack.iterator()); 
         }
         return null;
     }
@@ -343,14 +344,18 @@ public class FaceletCompositionContextIm
     }
     
     @Override
-    public void pushEnclosingValidatorIdToStack(String validatorId, EditableValueHolderAttachedObjectHandler attachedObjectHandler)
+    public void pushEnclosingValidatorIdToStack(String validatorId, 
+            EditableValueHolderAttachedObjectHandler attachedObjectHandler)
     {
         if (_enclosingValidatorIdsStack == null)
         {
-            _enclosingValidatorIdsStack = new LinkedList<Map.Entry<String, EditableValueHolderAttachedObjectHandler>>();
+            _enclosingValidatorIdsStack = 
+                new LinkedList<Map.Entry<String, EditableValueHolderAttachedObjectHandler>>();
         }
 
-        _enclosingValidatorIdsStack.addFirst(new SimpleEntry<String, EditableValueHolderAttachedObjectHandler>(validatorId, attachedObjectHandler));
+        _enclosingValidatorIdsStack.addFirst(
+                new SimpleEntry<String, EditableValueHolderAttachedObjectHandler>
+                    (validatorId, attachedObjectHandler));
     }
 
     public Iterator<Map.Entry<String, EditableValueHolderAttachedObjectHandler>> getEnclosingValidatorIdsAndHandlers()
@@ -795,30 +800,46 @@ public class FaceletCompositionContextIm
             return result;
         }
 
+        @SuppressWarnings("unchecked")
         @Override
         public boolean equals(Object obj)
         {
             if (this == obj)
+            {
                 return true;
+            }
             if (obj == null)
+            {
                 return false;
+            }
             if (getClass() != obj.getClass())
+            {
                 return false;
+            }
             SimpleEntry other = (SimpleEntry) obj;
             if (_key == null)
             {
                 if (other._key != null)
+                {
                     return false;
+                }
             }
             else if (!_key.equals(other._key))
+            {
                 return false;
+            }
+            
             if (_value == null)
             {
                 if (other._value != null)
+                {
                     return false;
+                }
             }
             else if (!_value.equals(other._value))
+            {
                 return false;
+            }
             return true;
         }
 

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java?rev=1195618&r1=1195617&r2=1195618&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java Mon Oct 31 19:03:29 2011
@@ -83,17 +83,23 @@ public final class MetaRulesetImpl exten
             // per classloader to hold metadata.
             synchronized (MetaRulesetImpl.metadata)
             {
-                metadata = (Map<String, MetadataTarget>) MetaRulesetImpl.metadata.get(cl);
-                if (metadata == null)
-                {
-                    metadata = new HashMap<String, MetadataTarget>();
-                    MetaRulesetImpl.metadata.put(cl, metadata);
-                }
+                metadata = createMetaData(cl, metadata);
             }
         }
 
         return metadata;
     }
+    
+    private static Map<String, MetadataTarget> createMetaData(ClassLoader cl, Map<String, MetadataTarget> metadata)
+    {
+        metadata = (Map<String, MetadataTarget>) MetaRulesetImpl.metadata.get(cl);
+        if (metadata == null)
+        {
+            metadata = new HashMap<String, MetadataTarget>();
+            MetaRulesetImpl.metadata.put(cl, metadata);
+        }
+        return metadata;
+    }
 
     private final Map<String, TagAttribute> _attributes;
 

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java?rev=1195618&r1=1195617&r2=1195618&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java Mon Oct 31 19:03:29 2011
@@ -19,7 +19,6 @@
 package org.apache.myfaces.view.facelets.tag.jsf;
 
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -508,11 +507,14 @@ public class ComponentTagHandlerDelegate
      * @param mctx the AbstractFaceletContext
      * @param component The EditableValueHolder to which the validators should be added
      */
-    private void addEnclosingAndDefaultValidators(FaceletContext ctx, FaceletCompositionContext mctx, FacesContext context, 
+    private void addEnclosingAndDefaultValidators(FaceletContext ctx, 
+                                      FaceletCompositionContext mctx, 
+                                      FacesContext context, 
                                       EditableValueHolder component)
     {
         // add all enclosing validators, because they have precedence over default validators.
-        Iterator<Map.Entry<String, EditableValueHolderAttachedObjectHandler>> enclosingValidatorIds = mctx.getEnclosingValidatorIdsAndHandlers();
+        Iterator<Map.Entry<String, EditableValueHolderAttachedObjectHandler>> enclosingValidatorIds =
+            mctx.getEnclosingValidatorIdsAndHandlers();
         if (enclosingValidatorIds != null)
         {
             while (enclosingValidatorIds.hasNext())
@@ -658,7 +660,8 @@ public class ComponentTagHandlerDelegate
                 }
             }
         }*/
-        Iterator<Map.Entry<String, EditableValueHolderAttachedObjectHandler>> enclosingValidatorIds = mctx.getEnclosingValidatorIdsAndHandlers();
+        Iterator<Map.Entry<String, EditableValueHolderAttachedObjectHandler>> enclosingValidatorIds =
+            mctx.getEnclosingValidatorIdsAndHandlers();
         if (enclosingValidatorIds != null)
         {
             while (enclosingValidatorIds.hasNext())
@@ -667,7 +670,8 @@ public class ComponentTagHandlerDelegate
                 boolean validatorIdAvailable = entry.getKey() != null && !"".equals(entry.getKey());
                 if (validatorIdAvailable && entry.getKey().equals(validatorId))
                 {
-                    if (((ValidatorHandler)((FacesWrapper<ValidatorHandler>)entry.getValue()).getWrapped()).isDisabled(ctx))
+                    if (((ValidatorHandler)((FacesWrapper<ValidatorHandler>)entry.getValue()).getWrapped())
+                            .isDisabled(ctx))
                     {
                         return false;
                     }
@@ -695,7 +699,8 @@ public class ComponentTagHandlerDelegate
     }
 
     private void addEnclosingValidator(FaceletContext ctx, FaceletCompositionContext mctx, FacesContext context, 
-            EditableValueHolder component, String validatorId, EditableValueHolderAttachedObjectHandler attachedObjectHandler)
+            EditableValueHolder component, String validatorId, 
+            EditableValueHolderAttachedObjectHandler attachedObjectHandler)
     {
         if (shouldAddEnclosingValidator(mctx, context, component, validatorId))
         {

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ValidatorTagHandlerDelegate.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ValidatorTagHandlerDelegate.java?rev=1195618&r1=1195617&r2=1195618&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ValidatorTagHandlerDelegate.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ValidatorTagHandlerDelegate.java Mon Oct 31 19:03:29 2011
@@ -27,7 +27,6 @@ import javax.faces.FacesWrapper;
 import javax.faces.component.EditableValueHolder;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
-import javax.faces.validator.BeanValidator;
 import javax.faces.validator.Validator;
 import javax.faces.view.EditableValueHolderAttachedObjectHandler;
 import javax.faces.view.facelets.ComponentHandler;
@@ -54,7 +53,8 @@ import org.apache.myfaces.view.facelets.
  *
  * @since 2.0
  */
-public class ValidatorTagHandlerDelegate extends TagHandlerDelegate implements EditableValueHolderAttachedObjectHandler, FacesWrapper<ValidatorHandler>
+public class ValidatorTagHandlerDelegate extends TagHandlerDelegate 
+    implements EditableValueHolderAttachedObjectHandler, FacesWrapper<ValidatorHandler>
 {
     
     /**