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 2013/09/23 16:34:33 UTC

svn commit: r1525606 - in /myfaces/core/trunk/impl/src: main/java/org/apache/myfaces/view/facelets/compiler/ main/java/org/apache/myfaces/view/facelets/tag/composite/ main/java/org/apache/myfaces/view/facelets/tag/jsf/ test/java/org/apache/myfaces/view...

Author: lu4242
Date: Mon Sep 23 14:34:32 2013
New Revision: 1525606

URL: http://svn.apache.org/r1525606
Log:
MYFACES-3733 Implement vdl.createComponent(...) 

Added:
    myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/component/UIAddSimpleCCVDL2.java
      - copied, changed from r1525536, myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/component/UIAddSimpleCCVDL.java
    myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/CheckActionEventBean.java
    myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ComponentBindingVDLBean2.java
      - copied, changed from r1525536, myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ComponentBindingVDLBean1.java
    myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/addSimpleCCVDL2.xhtml
      - copied, changed from r1525536, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/addSimpleComponentVDL.xhtml
    myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/componentBindingVDL_2.xhtml
      - copied, changed from r1525536, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/componentBindingVDL_1.xhtml
    myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/dynComp_2.xhtml
      - copied, changed from r1525536, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/dynComp_1.xhtml
Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/RefreshDynamicComponentListener.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CreateDynamicCompositeComponentListener.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java
    myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/RefreshDynamicComponentListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/RefreshDynamicComponentListener.java?rev=1525606&r1=1525605&r2=1525606&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/RefreshDynamicComponentListener.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/RefreshDynamicComponentListener.java Mon Sep 23 14:34:32 2013
@@ -94,27 +94,53 @@ public final class RefreshDynamicCompone
             facesContext.getAttributes().put(FaceletViewDeclarationLanguage.REFRESHING_TRANSIENT_BUILD,
                 Boolean.TRUE);
             
-            // The trick here is restore MARK_CREATED, just to allow ComponentTagHandlerDelegate to
-            // find the component. Then we reset it to exclude it from facelets refresh algorithm.
-            // Note oam.vf.GEN_MARK_ID helps to identify when there is a wrapper component or not,
-            // and in that way identify which component is the parent.
-            String markId = (String) component.getAttributes().get("oam.vf.GEN_MARK_ID");
-            if (markId == null)
+            
+            // Detect the relationship between parent and child, to ensure the component is properly created
+            // and refreshed. In facelets this is usually done by core.FacetHandler, but since it is a 
+            // dynamic component, we need to do it here before apply the handler
+            UIComponent parent = component.getParent();
+            String facetName = null;
+            if (parent.getFacetCount() > 0 && !parent.getChildren().contains(component))
             {
-                ((AbstractFacelet)componentFacelet).applyDynamicComponentHandler(
-                    facesContext, component, baseKey);
+                facetName = ComponentSupport.findFacetNameByComponentInstance(parent, component);
             }
-            else
+
+            try
             {
-                try
+                if (facetName != null)
+                {
+                    parent.getAttributes().put(org.apache.myfaces.view.facelets.tag.jsf.core.FacetHandler.KEY, 
+                            facetName);
+                }            
+                // The trick here is restore MARK_CREATED, just to allow ComponentTagHandlerDelegate to
+                // find the component. Then we reset it to exclude it from facelets refresh algorithm.
+                // Note oam.vf.GEN_MARK_ID helps to identify when there is a wrapper component or not,
+                // and in that way identify which component is the parent.
+                String markId = (String) component.getAttributes().get("oam.vf.GEN_MARK_ID");
+                if (markId == null)
                 {
-                    component.getAttributes().put(ComponentSupport.MARK_CREATED, markId);
                     ((AbstractFacelet)componentFacelet).applyDynamicComponentHandler(
-                        facesContext, component.getParent(), baseKey);
+                        facesContext, component, baseKey);
                 }
-                finally
+                else
+                {
+                    try
+                    {
+                        component.getAttributes().put(ComponentSupport.MARK_CREATED, markId);
+                        ((AbstractFacelet)componentFacelet).applyDynamicComponentHandler(
+                            facesContext, component.getParent(), baseKey);
+                    }
+                    finally
+                    {
+                        component.getAttributes().put(ComponentSupport.MARK_CREATED, null);
+                    }
+                }
+            }
+            finally
+            {
+                if (facetName != null)
                 {
-                    component.getAttributes().put(ComponentSupport.MARK_CREATED, null);
+                    parent.getAttributes().remove(org.apache.myfaces.view.facelets.tag.jsf.core.FacetHandler.KEY);
                 }
             }
         }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CreateDynamicCompositeComponentListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CreateDynamicCompositeComponentListener.java?rev=1525606&r1=1525605&r2=1525606&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CreateDynamicCompositeComponentListener.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CreateDynamicCompositeComponentListener.java Mon Sep 23 14:34:32 2013
@@ -80,43 +80,73 @@ public class CreateDynamicCompositeCompo
         {
             FaceletFactory.setInstance(null);
         }
+        
+        UIComponent component = event.getComponent(); 
+        // The execution of this listener activated another call to PostAddToViewEvent, because
+        // ComponentTagHandlerDelegate removes and add the component again. This is necessary because
+        // the inner components also require the propagation of PostAddToViewEvent to refresh themselves.
+        // but this check avoids the duplicate call to the facelet, even if the duplicate call does not
+        // have any side effect (counts as a refresh).
+        Integer step = (Integer) component.getAttributes().get(
+            CompositeComponentResourceTagHandler.CREATE_CC_ON_POST_ADD_TO_VIEW); 
+        if (step != null && step.intValue() == 0)
+        {
+            component.getAttributes().put(CompositeComponentResourceTagHandler.CREATE_CC_ON_POST_ADD_TO_VIEW, 1);
+        }
+        else
+        {
+            return;
+        }
         try
         {
-            UIComponent component = event.getComponent(); 
-            
-            Integer step = (Integer) component.getAttributes().get(
-                CompositeComponentResourceTagHandler.CREATE_CC_ON_POST_ADD_TO_VIEW); 
-            if (step != null && step.intValue() == 0)
-            {
-                component.getAttributes().put(CompositeComponentResourceTagHandler.CREATE_CC_ON_POST_ADD_TO_VIEW, 1);
-            }
-            else
-            {
-                return;
-            }
-            
             facesContext.getAttributes().put(FaceletViewDeclarationLanguage.REFRESHING_TRANSIENT_BUILD,
                 Boolean.TRUE);
             
-            // The trick here is restore MARK_CREATED, just to allow ComponentTagHandlerDelegate to
-            // find the component. Then we reset it to exclude it from facelets refresh algorithm.
-            String markId = (String) component.getAttributes().get("oam.vf.GEN_MARK_ID");
-            if (markId == null)
+            // Detect the relationship between parent and child, to ensure the component is properly created
+            // and refreshed. In facelets this is usually done by core.FacetHandler, but since it is a 
+            // dynamic component, we need to do it here before apply the handler
+            UIComponent parent = component.getParent();
+            String facetName = null;
+            if (parent.getFacetCount() > 0 && !parent.getChildren().contains(component))
             {
-                ((AbstractFacelet)componentFacelet).applyDynamicComponentHandler(
-                    facesContext, component, baseKey);
+                facetName = ComponentSupport.findFacetNameByComponentInstance(parent, component);
             }
-            else
+            
+            
+            try
             {
-                try
+                if (facetName != null)
+                {
+                    parent.getAttributes().put(org.apache.myfaces.view.facelets.tag.jsf.core.FacetHandler.KEY, 
+                            facetName);
+                }
+                // The trick here is restore MARK_CREATED, just to allow ComponentTagHandlerDelegate to
+                // find the component. Then we reset it to exclude it from facelets refresh algorithm.
+                String markId = (String) component.getAttributes().get("oam.vf.GEN_MARK_ID");
+                if (markId == null)
                 {
-                    component.getAttributes().put(ComponentSupport.MARK_CREATED, markId);
                     ((AbstractFacelet)componentFacelet).applyDynamicComponentHandler(
-                        facesContext, component.getParent(), baseKey);
+                        facesContext, component, baseKey);
                 }
-                finally
+                else
+                {
+                    try
+                    {
+                        component.getAttributes().put(ComponentSupport.MARK_CREATED, markId);
+                        ((AbstractFacelet)componentFacelet).applyDynamicComponentHandler(
+                            facesContext, component.getParent(), baseKey);
+                    }
+                    finally
+                    {
+                        component.getAttributes().put(ComponentSupport.MARK_CREATED, null);
+                    }
+                }
+            }
+            finally
+            {
+                if (facetName != null)
                 {
-                    component.getAttributes().put(ComponentSupport.MARK_CREATED, null);
+                    parent.getAttributes().remove(org.apache.myfaces.view.facelets.tag.jsf.core.FacetHandler.KEY);
                 }
             }
         }

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java?rev=1525606&r1=1525605&r2=1525606&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java Mon Sep 23 14:34:32 2013
@@ -165,6 +165,53 @@ public final class ComponentSupport
         }
         return null;
     }
+    
+    public static String findFacetNameByComponentInstance(
+        UIComponent parent, UIComponent instance)
+    {
+        if (parent.getFacetCount() > 0)
+        {
+            for (Map.Entry<String, UIComponent> entry : parent.getFacets().entrySet())
+            {
+                UIComponent facet = entry.getValue();
+                // check if this is a dynamically generated UIPanel
+                if (Boolean.TRUE.equals(facet.getAttributes()
+                             .get(FACET_CREATED_UIPANEL_MARKER)))
+                {
+                    // only check the children and facets of the panel
+                    if (facet.getChildCount() > 0)
+                    {
+                        for (int i = 0, childCount = facet.getChildCount(); i < childCount; i ++)
+                        {
+                            UIComponent child = facet.getChildren().get(i);
+                            if (instance.equals(child))
+                            {
+                                return entry.getKey();
+                            }
+                        }
+                    }
+                    if (facet.getFacetCount() > 0)
+                    {
+                        Iterator<UIComponent> itr2 = facet.getFacets().values().iterator();
+                        while (itr2.hasNext())
+                        {
+                            UIComponent child = itr2.next();
+                            if (instance.equals(child))
+                            {
+                                return entry.getKey();
+                            }
+                        }
+                    }
+                }
+                else if (instance.equals(facet))
+                {
+                    return entry.getKey();
+                }
+            }
+            return null;
+        }
+        return null;
+    }
 
     public static UIComponent findChildInFacetByTagId(
         UIComponent parent, String id, String facetName)

Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java?rev=1525606&r1=1525605&r2=1525606&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java Mon Sep 23 14:34:32 2013
@@ -31,6 +31,7 @@ import junit.framework.Assert;
 import org.apache.myfaces.mc.test.core.AbstractMyFacesRequestTestCase;
 import org.apache.myfaces.shared.config.MyfacesConfig;
 import org.apache.myfaces.test.mock.MockPrintWriter;
+import org.apache.myfaces.view.facelets.pss.acid.managed.CheckActionEventBean;
 import org.apache.myfaces.view.facelets.pss.acid.managed.ResourceDependencyBean;
 import org.junit.Test;
 
@@ -740,7 +741,48 @@ public class AcidMyFacesRequestTestCase 
 
         tearDownRequest();
     }
-    
+
+    @Test
+    public void testAddSimpleCCVDL2() throws Exception
+    {
+        setupRequest("/addSimpleCCVDL2.xhtml");
+        processLifecycleExecuteAndRender();
+        
+        UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
+        Assert.assertEquals(1, comp.getChildCount());
+        UIComponent wrapper = comp.getChildren().get(0);
+        Assert.assertNotNull(wrapper);
+        Assert.assertTrue(UIComponent.isCompositeComponent(wrapper));
+        UIComponent ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME);
+        Assert.assertNotNull(ccContent);
+        Assert.assertEquals(3, ccContent.getChildCount());
+        Assert.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value"));
+        MockPrintWriter writer1 = (MockPrintWriter) response.getWriter();
+        String content1 = new String(writer1.content());
+        Assert.assertTrue(content1.contains("Dynamically added header"));
+        Assert.assertTrue(content1.contains("Dynamically added markup"));
+        
+        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
+        submit(button);
+        processLifecycleExecuteAndRender();
+        
+        comp = facesContext.getViewRoot().findComponent("mainForm:component");
+        Assert.assertEquals(1, comp.getChildCount());
+        wrapper = comp.getChildren().get(0);
+        Assert.assertNotNull(wrapper);
+        Assert.assertTrue(UIComponent.isCompositeComponent(wrapper));
+        ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME);
+        Assert.assertNotNull(ccContent);
+        Assert.assertEquals(3, ccContent.getChildCount());
+        Assert.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value"));
+        MockPrintWriter writer2 = (MockPrintWriter) response.getWriter();
+        String content2 = new String(writer2.content());
+        Assert.assertTrue(content2.contains("Dynamically added header"));
+        Assert.assertTrue(content2.contains("Dynamically added markup"));
+
+        tearDownRequest();
+    }
+
     @Test
     public void testComponentBindingVDL_1() throws Exception
     {
@@ -761,7 +803,8 @@ public class AcidMyFacesRequestTestCase 
             ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value"));
         Assert.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value"));
         MockPrintWriter writer1 = (MockPrintWriter) response.getWriter();
-        Assert.assertTrue(new String(writer1.content()).contains("Dynamically added markup"));
+        String content1 = new String(writer1.content());
+        Assert.assertTrue(content1.contains("Dynamically added markup"));
         
         UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
         submit(button);
@@ -784,7 +827,8 @@ public class AcidMyFacesRequestTestCase 
             ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value"));
         Assert.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value"));
         MockPrintWriter writer2 = (MockPrintWriter) response.getWriter();
-        Assert.assertTrue(new String(writer2.content()).contains("Dynamically added markup"));
+        String content2 = new String(writer2.content());
+        Assert.assertTrue(content2.contains("Dynamically added markup"));
         
         button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
         submit(button);
@@ -807,8 +851,101 @@ public class AcidMyFacesRequestTestCase 
             ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value"));
         Assert.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value"));
         MockPrintWriter writer3 = (MockPrintWriter) response.getWriter();
-        Assert.assertTrue(new String(writer3.content()).contains("Dynamically added markup"));
+        String content3 = new String(writer3.content());
+        Assert.assertTrue(content3.contains("Dynamically added markup"));
         
         tearDownRequest();
-    }    
+    }
+    
+    @Test
+    public void testComponentBindingVDL_2() throws Exception
+    {
+        setupRequest("/componentBindingVDL_2.xhtml");
+        processLifecycleExecuteAndRender();
+        
+        UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:panel");
+        Assert.assertNotNull(comp);
+        Assert.assertEquals(2, comp.getChildCount());
+
+        UIComponent wrapper = comp.getChildren().get(1);
+        Assert.assertNotNull(wrapper);
+        Assert.assertTrue(UIComponent.isCompositeComponent(wrapper));
+        UIComponent ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME);
+        Assert.assertNotNull(ccContent);
+        Assert.assertEquals(3, ccContent.getChildCount());
+        Assert.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value"));
+        MockPrintWriter writer1 = (MockPrintWriter) response.getWriter();
+        String content1 = new String(writer1.content());
+        Assert.assertTrue(content1.contains("Dynamically added header"));
+        Assert.assertTrue(content1.contains("Dynamically added markup"));
+        
+        UIComponent ccpanel = facesContext.getViewRoot().findComponent("mainForm:ccpanel");
+        Assert.assertNotNull(ccpanel);
+        UIComponent ccinnerpanel = facesContext.getViewRoot().findComponent("mainForm:ccpanel:component");
+        Assert.assertNotNull(ccinnerpanel);
+        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:ccpanel:component:increment");
+        Assert.assertNotNull(button);
+        
+        CheckActionEventBean checkBean = facesContext.getApplication().evaluateExpressionGet(facesContext,
+                "#{checkActionEventBean}", CheckActionEventBean.class);
+        int oldcount1 = checkBean.getActionListenerCount();
+        
+        submit(button);
+        processLifecycleExecute();
+        
+        Assert.assertEquals("event not called", oldcount1+1, checkBean.getActionListenerCount());
+        processRender();
+
+        Assert.assertNotNull(comp);
+        Assert.assertEquals(2, comp.getChildCount());
+        
+        comp = facesContext.getViewRoot().findComponent("mainForm:panel");
+        
+        Assert.assertEquals("value1", comp.getAttributes().get("attr1"));
+        Assert.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2"));
+        
+        wrapper = comp.getChildren().get(1);
+        Assert.assertNotNull(wrapper);
+        Assert.assertTrue(UIComponent.isCompositeComponent(wrapper));
+        ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME);
+        Assert.assertNotNull(ccContent);
+        Assert.assertEquals(3, ccContent.getChildCount());
+        Assert.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value"));
+        MockPrintWriter writer2 = (MockPrintWriter) response.getWriter();
+        String content2 = new String(writer2.content());
+        Assert.assertTrue(content2.contains("Dynamically added header"));
+        Assert.assertTrue(content2.contains("Dynamically added markup"));
+        
+        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:ccpanel:component:increment");
+        Assert.assertNotNull(button);
+        int oldcount2 = checkBean.getActionListenerCount();        
+        
+        submit(button);
+        processLifecycleExecute();
+        
+        Assert.assertEquals("event not called", oldcount2+1, checkBean.getActionListenerCount());
+        
+        processRender();
+        Assert.assertNotNull(comp);
+        Assert.assertEquals(2, comp.getChildCount());
+
+        comp = facesContext.getViewRoot().findComponent("mainForm:panel");
+        
+        Assert.assertEquals("value1", comp.getAttributes().get("attr1"));
+        Assert.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2"));
+        
+        wrapper = comp.getChildren().get(1);
+        Assert.assertNotNull(wrapper);
+        Assert.assertTrue(UIComponent.isCompositeComponent(wrapper));
+        ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME);
+        Assert.assertNotNull(ccContent);
+        Assert.assertEquals(3, ccContent.getChildCount());
+        Assert.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value"));
+        MockPrintWriter writer3 = (MockPrintWriter) response.getWriter();
+        String content3 = new String(writer3.content());
+        Assert.assertTrue(content3.contains("Dynamically added header"));
+        Assert.assertTrue(content3.contains("Dynamically added markup"));
+        
+        tearDownRequest();
+    }
 }

Copied: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/component/UIAddSimpleCCVDL2.java (from r1525536, myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/component/UIAddSimpleCCVDL.java)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/component/UIAddSimpleCCVDL2.java?p2=myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/component/UIAddSimpleCCVDL2.java&p1=myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/component/UIAddSimpleCCVDL.java&r1=1525536&r2=1525606&rev=1525606&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/component/UIAddSimpleCCVDL.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/component/UIAddSimpleCCVDL2.java Mon Sep 23 14:34:32 2013
@@ -23,7 +23,6 @@ import java.util.Map;
 import javax.faces.component.FacesComponent;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIComponentBase;
-import javax.faces.component.UIOutput;
 import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
 import javax.faces.event.AbortProcessingException;
@@ -32,8 +31,9 @@ import javax.faces.event.SystemEvent;
 import javax.faces.event.SystemEventListener;
 import javax.faces.view.ViewDeclarationLanguage;
 
-@FacesComponent(value = "com.myapp.UIAddSimpleCCVDL")
-public class UIAddSimpleCCVDL extends UIComponentBase implements
+@FacesComponent(value = "com.myapp.UIAddSimpleCCVDL2", createTag=true, 
+        namespace="http://testcomponent", tagName="addSimpleCCVDL2")
+public class UIAddSimpleCCVDL2 extends UIComponentBase implements
         SystemEventListener
 {
 
@@ -41,14 +41,16 @@ public class UIAddSimpleCCVDL extends UI
     // Constructor
     //
 
-    public UIAddSimpleCCVDL()
+    public UIAddSimpleCCVDL2()
     {
         setRendererType(null);
 
         FacesContext context = FacesContext.getCurrentInstance();
         UIViewRoot root = context.getViewRoot();
-
-        root.subscribeToViewEvent(PreRenderViewEvent.class, this);
+        if (root != null)
+        {
+            root.subscribeToViewEvent(PreRenderViewEvent.class, this);
+        }
     }
 
     //
@@ -81,9 +83,12 @@ public class UIAddSimpleCCVDL extends UI
             UIComponent component = vdl.createComponent(facesContext, 
                 "http://java.sun.com/jsf/composite/testComposite", 
                 "dynComp_1", attributes);
-            UIOutput text = (UIOutput) facesContext.getApplication().
-                createComponent(UIOutput.COMPONENT_TYPE);
-            text.setValue("Dynamically added header");
+            
+            Map<String, Object> attributes2 = new HashMap<String, Object>();
+            UIComponent text = (UIComponent) vdl.createComponent(facesContext, 
+                "http://java.sun.com/jsf/composite/testComposite", 
+                "dynComp_2", attributes2);
+
             component.getFacets().put("header", text);
             
             getChildren().add(component);

Added: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/CheckActionEventBean.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/CheckActionEventBean.java?rev=1525606&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/CheckActionEventBean.java (added)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/CheckActionEventBean.java Mon Sep 23 14:34:32 2013
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.view.facelets.pss.acid.managed;
+
+import java.io.Serializable;
+import javax.annotation.PostConstruct;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.faces.event.ActionEvent;
+
+/**
+ *
+ * @author Leonardo Uribe
+ */
+@ManagedBean(name="checkActionEventBean")
+@SessionScoped
+public class CheckActionEventBean implements Serializable
+{
+    private int actionListenerCount;
+    
+    @PostConstruct
+    public void init()
+    {
+        actionListenerCount = 0;
+    }
+    
+    public void increment(ActionEvent evt)
+    {
+        actionListenerCount++;
+    }
+    
+    public int getActionListenerCount()
+    {
+        return actionListenerCount;
+    }
+}

Copied: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ComponentBindingVDLBean2.java (from r1525536, myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ComponentBindingVDLBean1.java)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ComponentBindingVDLBean2.java?p2=myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ComponentBindingVDLBean2.java&p1=myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ComponentBindingVDLBean1.java&r1=1525536&r2=1525606&rev=1525606&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ComponentBindingVDLBean1.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ComponentBindingVDLBean2.java Mon Sep 23 14:34:32 2013
@@ -33,9 +33,9 @@ import javax.faces.view.ViewDeclarationL
  *
  * @author Leonardo Uribe
  */
-@ManagedBean(name="componentBindingVDLBean1")
+@ManagedBean(name="componentBindingVDLBean2")
 @RequestScoped
-public class ComponentBindingVDLBean1
+public class ComponentBindingVDLBean2
 {
     private UIPanel panel;
     
@@ -66,9 +66,14 @@ public class ComponentBindingVDLBean1
             UIComponent cc = vdl.createComponent(facesContext, 
                 "http://java.sun.com/jsf/composite/testComposite", 
                 "dynComp_1", attributes);
-            UIOutput text = (UIOutput) facesContext.getApplication().
-                createComponent(UIOutput.COMPONENT_TYPE);
-            text.setValue("Dynamically added header");
+            cc.setId("ccpanel");
+            
+            Map<String, Object> attributes2 = new HashMap<String, Object>();
+            UIComponent text = (UIComponent) vdl.createComponent(facesContext, 
+                "http://java.sun.com/jsf/composite/testComposite", 
+                "dynComp_2", attributes2);
+            text.setId("component");
+
             cc.getFacets().put("header", text);
             panel.getChildren().add(cc);
 

Copied: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/addSimpleCCVDL2.xhtml (from r1525536, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/addSimpleComponentVDL.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/addSimpleCCVDL2.xhtml?p2=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/addSimpleCCVDL2.xhtml&p1=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/addSimpleComponentVDL.xhtml&r1=1525536&r2=1525606&rev=1525606&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/addSimpleComponentVDL.xhtml (original)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/addSimpleCCVDL2.xhtml Mon Sep 23 14:34:32 2013
@@ -30,7 +30,7 @@
 		
 	<h:form id="mainForm">
 	
-		<test:addSimpleComponentVDL id="component"/>
+		<test:addSimpleCCVDL2 id="component"/>
 		
 		<br/>
 		

Copied: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/componentBindingVDL_2.xhtml (from r1525536, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/componentBindingVDL_1.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/componentBindingVDL_2.xhtml?p2=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/componentBindingVDL_2.xhtml&p1=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/componentBindingVDL_1.xhtml&r1=1525536&r2=1525606&rev=1525606&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/componentBindingVDL_1.xhtml (original)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/componentBindingVDL_2.xhtml Mon Sep 23 14:34:32 2013
@@ -19,8 +19,8 @@
 <h:head>
 </h:head>
 <h:body>
-  <h:panelGroup id="panel" binding="#{componentBindingVDLBean1.panel}"/>
   <h:form id="mainForm">
+     <h:panelGroup id="panel" binding="#{componentBindingVDLBean2.panel}"/>
      <h:commandButton id="postback" value="POSTBACK"/>
   </h:form>
 </h:body>

Copied: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/dynComp_2.xhtml (from r1525536, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/dynComp_1.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/dynComp_2.xhtml?p2=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/dynComp_2.xhtml&p1=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/dynComp_1.xhtml&r1=1525536&r2=1525606&rev=1525606&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/dynComp_1.xhtml (original)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/dynComp_2.xhtml Mon Sep 23 14:34:32 2013
@@ -6,13 +6,9 @@
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:cc="http://java.sun.com/jsf/composite">
 <cc:interface>
-    <cc:facet name="header" required="true"/>
 </cc:interface>
 <cc:implementation>
-    <h:panelGrid>
-        <cc:insertFacet name="header"/>
-    </h:panelGrid>
-    Dynamically added markup
-    <h:outputText value="Dynamically added child"/>
+    <h:outputText value="Dynamically added header"/>
+    <h:commandButton id="increment" value="Increment" actionListener="#{checkActionEventBean.increment}"/>
 </cc:implementation>
 </html>
\ No newline at end of file