You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2018/11/07 08:53:41 UTC

[myfaces] branch master updated: MYFACES-4082 Composite component doesn't work

This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/master by this push:
     new 3c5464e  MYFACES-4082 Composite component doesn't work
3c5464e is described below

commit 3c5464eb9e5624a4b01d560577b1b408301c51fa
Author: Thomas Andraschko <ta...@apache.org>
AuthorDate: Wed Nov 7 09:53:36 2018 +0100

    MYFACES-4082 Composite component doesn't work
---
 .../CompositeComponentResourceTagHandler.java      | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentResourceTagHandler.java b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentResourceTagHandler.java
index f0c2041..2ccf4a8 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentResourceTagHandler.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentResourceTagHandler.java
@@ -42,6 +42,7 @@ import javax.faces.component.UIPanel;
 import javax.faces.component.UniqueIdVendor;
 import javax.faces.component.ValueHolder;
 import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseId;
 import javax.faces.view.AttachedObjectHandler;
 import javax.faces.view.ViewDeclarationLanguage;
 import javax.faces.view.facelets.ComponentConfig;
@@ -62,9 +63,11 @@ import org.apache.myfaces.view.facelets.el.VariableMapperWrapper;
 import org.apache.myfaces.view.facelets.tag.ComponentContainerHandler;
 import org.apache.myfaces.view.facelets.tag.TagHandlerUtils;
 import org.apache.myfaces.view.facelets.tag.jsf.ActionSourceRule;
+import org.apache.myfaces.view.facelets.tag.jsf.ClearBindingValueExpressionListener;
 import org.apache.myfaces.view.facelets.tag.jsf.ComponentBuilderHandler;
 import org.apache.myfaces.view.facelets.tag.jsf.ComponentSupport;
 import org.apache.myfaces.view.facelets.tag.jsf.EditableValueHolderRule;
+import org.apache.myfaces.view.facelets.tag.jsf.PreDisposeViewEvent;
 import org.apache.myfaces.view.facelets.tag.jsf.ValueHolderRule;
 import org.apache.myfaces.view.facelets.tag.jsf.core.AjaxHandler;
 
@@ -107,11 +110,30 @@ public class CompositeComponentResourceTagHandler extends ComponentHandler
         _dynamicCompositeComponent = false;
     }
 
+    @Override
     public UIComponent createComponent(FaceletContext ctx)
     {
         FacesContext facesContext = ctx.getFacesContext();
         UIComponent component = facesContext.getApplication().createComponent(facesContext, _resource);
         
+        if (getBinding() != null)
+        {
+            ValueExpression bindingVE = getBinding().getValueExpression(ctx, Object.class);
+            component.setValueExpression("binding", bindingVE);
+            
+            if (!bindingVE.isReadOnly(facesContext.getELContext()))
+            {
+                if (PhaseId.RESTORE_VIEW.equals(facesContext.getCurrentPhaseId()))
+                {
+                    bindingVE.setValue(ctx, component);
+                }
+                
+                ComponentSupport.getViewRoot(ctx, component)
+                        .getAttributes().put("oam.CALL_PRE_DISPOSE_VIEW", Boolean.TRUE);
+                component.subscribeToEvent(PreDisposeViewEvent.class, new ClearBindingValueExpressionListener());
+            }
+        }
+        
         // Check required attributes if the app is not on production stage. 
         // Unfortunately, we can't check it on constructor because we need to call
         // ViewDeclarationLanguage.getComponentMetadata() and on that point it is possible to not
@@ -521,6 +543,7 @@ public class CompositeComponentResourceTagHandler extends ComponentHandler
         }
     }
     
+    @Override
     public boolean apply(FaceletContext ctx, UIComponent parent, String name)
             throws IOException, FacesException, FaceletException, ELException
     {