https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1727
Thanks to Max Starets for suggesting this idea.
Force implicit panel children to be inspected in Facelets mark and sweep algorithm
https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1727
SECTION: Modified Files
----------------------------
M jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentSupport.java
- in markForDeletion(), add an additional clause to cause the children
of the implict panel to be marked for deletion as well. If there are
tag handlers for any of the children, then they will naturally be
retained in the usual manner.
- in finalizeForDeletion, add an additional clause to cause the children
of the implicit panel to be removed if, in the usual course of facelet
processing, they are not retained.
SECTION: Diffs
----------------------------
Index: jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentSupport.java
===================================================================
--- jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentSupport.java (revision 8543)
+++ jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentSupport.java (working copy)
@@ -119,10 +119,22 @@
if (c.getFacets().size() > 0) {
Collection col = c.getFacets().values();
UIComponent fc;
- for (Iterator itr = col.iterator(); itr.hasNext();) {
- fc = (UIComponent) itr.next();
- if (fc.getAttributes().containsKey(MARK_DELETED)) {
+ for (Iterator<UIComponent> itr = col.iterator(); itr.hasNext();) {
+ fc = itr.next();
+ Map<String, Object> attrs = fc.getAttributes();
+ if (attrs.containsKey(MARK_DELETED)) {
itr.remove();
+ } else if (attrs.containsKey(IMPLICIT_PANEL)){
+ List<UIComponent> implicitPanelChildren = fc.getChildren();
+ UIComponent innerChild;
+ for (Iterator<UIComponent> innerItr = implicitPanelChildren.iterator();
+ innerItr.hasNext();) {
+ innerChild = innerItr.next();
+ if (innerChild.getAttributes().containsKey(MARK_DELETED)) {
+ innerItr.remove();
+ }
+
+ }
}
}
}
@@ -311,8 +323,18 @@
UIComponent fc;
for (Iterator itr = col.iterator(); itr.hasNext();) {
fc = (UIComponent) itr.next();
- if (fc.getAttributes().containsKey(MARK_CREATED)) {
- fc.getAttributes().put(MARK_DELETED, Boolean.TRUE);
+ Map<String, Object> attrs = fc.getAttributes();
+ if (attrs.containsKey(MARK_CREATED)) {
+ attrs.put(MARK_DELETED, Boolean.TRUE);
+ } else if (attrs.containsKey(IMPLICIT_PANEL)) {
+ List<UIComponent> implicitPanelChildren = fc.getChildren();
+ Map<String, Object> innerAttrs = null;
+ for (UIComponent cur : implicitPanelChildren) {
+ innerAttrs = cur.getAttributes();
+ if (innerAttrs.containsKey(MARK_CREATED)) {
+ innerAttrs.put(MARK_DELETED, Boolean.TRUE);
+ }
+ }
}
}
}
@@ -388,8 +410,10 @@
if (!(existing instanceof UIPanel)) {
// move existing component under a panel group
UIComponent panelGroup = ctx.getFacesContext().getApplication().createComponent(UIPanel.COMPONENT_TYPE);
- panelGroup.setId(getViewRoot(ctx.getFacesContext(), parent).createUniqueId());
- panelGroup.getAttributes().put(ComponentSupport.IMPLICIT_PANEL, true);
+ String id = null;
+ panelGroup.setId(id = getViewRoot(ctx.getFacesContext(), parent).createUniqueId());
+ Map<String, Object> attrs = panelGroup.getAttributes();
+ attrs.put(ComponentSupport.IMPLICIT_PANEL, true);
panelGroup.getChildren().add(existing);
// the panel group becomes the facet
parent.getFacets().put(facetName, panelGroup);
--
| edburns_at_oracle.com | office: +1 407 458 0017
| homepage: | http://ridingthecrest.com/
| 07 work days until JSF 2.1 Milestone 2