Skip to content
Browse files

MYFACES-3665 f:metadata section removed when refresh view and is not …

…included in the template directly

git-svn-id: https://svn.apache.org/repos/asf/myfaces/core/trunk@1423194 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 277c60f commit 276f60a1f6cef025688f6b4cbdb25397a5b7a154 Leonardo Uribe committed Dec 17, 2012
View
4 impl/src/main/java/org/apache/myfaces/view/facelets/FaceletCompositionContext.java
@@ -336,6 +336,10 @@ public boolean isRefreshTransientBuildOnPSSPreserveState()
* UIComponent to finalize
*/
public abstract void finalizeForDeletion(UIComponent component);
+
+ public void removeComponentForDeletion(UIComponent component)
+ {
+ }
/**
* Add a method expression as targeted for the provided composite component
View
14 impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFacelet.java
@@ -40,6 +40,7 @@
import javax.faces.FacesException;
import javax.faces.application.Resource;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
import javax.faces.component.UniqueIdVendor;
import javax.faces.context.FacesContext;
import javax.faces.view.facelets.FaceletContext;
@@ -177,6 +178,19 @@ public void apply(FacesContext facesContext, UIComponent parent) throws IOExcept
this.refresh(parent);
myFaceletContext.markForDeletion(parent);
_root.apply(ctx, parent);
+ if (faceletCompositionContextInitialized &&
+ parent instanceof UIViewRoot)
+ {
+ UIComponent metadataFacet = parent.getFacet(UIViewRoot.METADATA_FACET_NAME);
+ if (metadataFacet != null)
+ {
+ // Ensure metadata facet is removed from deletion, so if by some reason
+ // is not refreshed, its content will not be removed from the component tree.
+ // This behavior is preferred, even if the spec suggest to include it using
+ // a trick with the template client.
+ myFaceletContext.removeComponentForDeletion(metadataFacet);
+ }
+ }
myFaceletContext.finalizeForDeletion(parent);
this.markApplied(parent);
View
26 impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCompositionContextImpl.java
@@ -820,6 +820,32 @@ else if (Boolean.TRUE.equals(fc.getAttributes().get(ComponentSupport.FACET_CREAT
}
}
+ @Override
+ public void removeComponentForDeletion(UIComponent component)
+ {
+ String id = (String) component.getAttributes().get(ComponentSupport.MARK_CREATED);
+ if (id != null)
+ {
+ removeComponentForDeletion(id);
+ }
+ else if (id == null
+ && Boolean.TRUE.equals(component.getAttributes().get(ComponentSupport.FACET_CREATED_UIPANEL_MARKER)))
+ {
+ if (component.getChildCount() > 0)
+ {
+ for (int i = 0, size = component.getChildCount(); i < size; i++)
+ {
+ UIComponent child = component.getChildren().get(i);
+ id = (String) child.getAttributes().get(ComponentSupport.MARK_CREATED);
+ if (id != null)
+ {
+ removeComponentForDeletion(id);
+ }
+ }
+ }
+ }
+ }
+
public void finalizeForDeletion(UIComponent component)
{
String id = (String) component.getAttributes().get(ComponentSupport.MARK_CREATED);

0 comments on commit 276f60a

Please sign in to comment.
Something went wrong with that request. Please try again.