[ https://issues.apache.org/jira/browse/MYFACES-4082?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16678740#comment-16678740 ]
ASF GitHub Bot commented on MYFACES-4082: ----------------------------------------- tandraschko closed pull request #18: MYFACES-4082 Fix 'binding' when referencing composite components URL: https://github.com/apache/myfaces/pull/18 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): 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 f0c2041bd..5f95fc70d 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.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; @@ -51,6 +52,7 @@ import javax.faces.view.facelets.FaceletHandler; import javax.faces.view.facelets.MetaRuleset; import javax.faces.view.facelets.Metadata; +import javax.faces.view.facelets.TagAttribute; import javax.faces.view.facelets.TagException; import javax.faces.view.facelets.TextHandler; @@ -62,9 +64,11 @@ 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; @@ -109,10 +113,35 @@ public CompositeComponentResourceTagHandler(ComponentConfig config, Resource res public UIComponent createComponent(FaceletContext ctx) { + FacesContext facesContext = ctx.getFacesContext(); - UIComponent component = facesContext.getApplication().createComponent(facesContext, _resource); - - // Check required attributes if the app is not on production stage. + UIComponent component = facesContext.getApplication().createComponent(facesContext, this._resource); + + TagAttribute bindingAttribute = getBinding(); + + if (bindingAttribute != null) + { + + ValueExpression bindingVE = bindingAttribute.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 // have a viewId. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Composite component binding doesn't work > ---------------------------------------- > > Key: MYFACES-4082 > URL: https://issues.apache.org/jira/browse/MYFACES-4082 > Project: MyFaces Core > Issue Type: Bug > Affects Versions: 2.2.3, 2.2.11 > Environment: Debian 8.2 > JDK 1.8 > Netbeans 8.1 > Reporter: NCister > Priority: Major > Fix For: 2.2.13, 2.3.3, 3.0.0-SNAPSHOT > > > I've just tried to set binding of a simple composite. > It don't works :-( > To manage the componentType methods from user page the only way is to use > ViewRoot.findComponent ..... -- This message was sent by Atlassian JIRA (v7.6.3#76005)