Changes :
https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1680
All tests are passing.
https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1680
SECTION: Modified Files
----------------------------
M jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentTagHandlerDelegateImpl.java
M jsf-ri/src/main/java/com/sun/faces/facelets/tag/composite/InsertFacetHandler.java
M jsf-ri/src/main/java/com/sun/faces/facelets/tag/composite/InsertChildrenHandler.java
SECTION: Diffs
----------------------------
Index: jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentTagHandlerDelegateImpl.java
===================================================================
--- jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentTagHandlerDelegateImpl.java (revision 8549)
+++ jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentTagHandlerDelegateImpl.java (working copy)
@@ -138,6 +138,13 @@
// grab our component
UIComponent c = findChild(ctx, parent, id);
+ if (null == c &&
+ context.isPostback() &&
+ UIComponent.isCompositeComponent(parent) &&
+ parent.getAttributes().get(id) != null) {
+ c = findReparentedComponent(ctx, parent, id);
+ }
+
boolean componentFound = false;
if (c != null) {
componentFound = true;
@@ -427,7 +434,21 @@
}
+ @SuppressWarnings({"UnusedDeclaration"})
+ protected UIComponent findReparentedComponent(FaceletContext ctx,
+ UIComponent parent,
+ String tagId) {
+ UIComponent facet = parent.getFacets().get(UIComponent.COMPOSITE_FACET_NAME);
+ if (facet != null) {
+ UIComponent newParent = facet.findComponent(
+ (String)parent.getAttributes().get(tagId));
+ if (newParent != null)
+ return ComponentSupport.findChildByTagId(newParent, tagId);
+ }
+ return null;
+ }
+
// ------------------------------------------------- Package Private Methods
Index: jsf-ri/src/main/java/com/sun/faces/facelets/tag/composite/InsertFacetHandler.java
===================================================================
--- jsf-ri/src/main/java/com/sun/faces/facelets/tag/composite/InsertFacetHandler.java (revision 8549)
+++ jsf-ri/src/main/java/com/sun/faces/facelets/tag/composite/InsertFacetHandler.java (working copy)
@@ -37,6 +37,7 @@
package com.sun.faces.facelets.tag.composite;
import com.sun.faces.facelets.tag.TagHandlerImpl;
+import com.sun.faces.facelets.tag.jsf.ComponentSupport;
import com.sun.faces.util.FacesLogger;
import javax.faces.component.UIComponent;
@@ -177,6 +178,15 @@
}
if (facet != null) {
component.getFacets().put(facetName, facet);
+
+ String key = (String)facet.getAttributes().get(ComponentSupport.MARK_CREATED);
+
+ String value = component.getId();
+ if (key != null && value != null) {
+ //store the new parent's info per child in the old parent's attr map
+ compositeParent.getAttributes().put(key, value);
+ }
+
} else {
// In the case of full state saving, the compositeParent won't
// have the facet to be relocated as its own - it will have already
@@ -187,7 +197,7 @@
throwRequiredException(ctx, facetName, compositeParent);
}
}
-
+
}
Index: jsf-ri/src/main/java/com/sun/faces/facelets/tag/composite/InsertChildrenHandler.java
===================================================================
--- jsf-ri/src/main/java/com/sun/faces/facelets/tag/composite/InsertChildrenHandler.java (revision 8549)
+++ jsf-ri/src/main/java/com/sun/faces/facelets/tag/composite/InsertChildrenHandler.java (working copy)
@@ -38,6 +38,7 @@
package com.sun.faces.facelets.tag.composite;
import com.sun.faces.facelets.tag.TagHandlerImpl;
+import com.sun.faces.facelets.tag.jsf.ComponentSupport;
import com.sun.faces.util.FacesLogger;
import javax.faces.component.UIComponent;
@@ -168,7 +169,19 @@
List<UIComponent> compositeChildren = compositeParent.getChildren();
List<UIComponent> parentChildren = component.getChildren();
+
+ //store the new parent's info per child in the old parent's attr map
+ //<child id, new parent>
+ for (UIComponent c : compositeChildren) {
+ String key = (String)c.getAttributes().get(ComponentSupport.MARK_CREATED);
+ String value = component.getId();
+ if (key != null && value != null) {
+ compositeParent.getAttributes().put(key, value);
+ }
+ }
+
parentChildren.addAll(getIdx(), compositeChildren);
+
}
SECTION: Modified Files
----------------------------
M jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentTagHandlerDelegateImpl.java
added a new method "findReparentedComponent()" to get the child from the new parent as part of the "insertChildren/insertFacet" tag handling.
M jsf-ri/src/main/java/com/sun/faces/facelets/tag/composite/InsertFacetHandler.java
M jsf-ri/src/main/java/com/sun/faces/facelets/tag/composite/InsertChildrenHandler.java
For both of the above handlers, added some code to store the child<->newparent mapping in the composite parent. This way, its easier to find the children during rendering phase.
SECTION: Diffs
----------------------------
Index: jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentTagHandlerDelegateImpl.java
===================================================================
--- jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentTagHandlerDelegateImpl.java (revision 8549)
+++ jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/ComponentTagHandlerDelegateImpl.java (working copy)
@@ -138,6 +138,13 @@
// grab our component
UIComponent c = findChild(ctx, parent, id);
+ if (null == c &&
+ context.isPostback() &&
+ UIComponent.isCompositeComponent(parent) &&
+ parent.getAttributes().get(id) != null) {
+ c = findReparentedComponent(ctx, parent, id);
+ }
+
boolean componentFound = false;
if (c != null) {
componentFound = true;
@@ -427,7 +434,21 @@
}
+ @SuppressWarnings({"UnusedDeclaration"})
+ protected UIComponent findReparentedComponent(FaceletContext ctx,
+ UIComponent parent,
+ String tagId) {
+ UIComponent facet = parent.getFacets().get(UIComponent.COMPOSITE_FACET_NAME);
+ if (facet != null) {
+ UIComponent newParent = facet.findComponent(
+ (String)parent.getAttributes().get(tagId));
+ if (newParent != null)
+ return ComponentSupport.findChildByTagId(newParent, tagId);
+ }
+ return null;
+ }
+
// ------------------------------------------------- Package Private Methods
Index: jsf-ri/src/main/java/com/sun/faces/facelets/tag/composite/InsertFacetHandler.java
===================================================================
--- jsf-ri/src/main/java/com/sun/faces/facelets/tag/composite/InsertFacetHandler.java (revision 8549)
+++ jsf-ri/src/main/java/com/sun/faces/facelets/tag/composite/InsertFacetHandler.java (working copy)
@@ -37,6 +37,7 @@
package com.sun.faces.facelets.tag.composite;
import com.sun.faces.facelets.tag.TagHandlerImpl;
+import com.sun.faces.facelets.tag.jsf.ComponentSupport;
import com.sun.faces.util.FacesLogger;
import javax.faces.component.UIComponent;
@@ -177,6 +178,15 @@
}
if (facet != null) {
component.getFacets().put(facetName, facet);
+
+ String key = (String)facet.getAttributes().get(ComponentSupport.MARK_CREATED);
+
+ String value = component.getId();
+ if (key != null && value != null) {
+ //store the new parent's info per child in the old parent's attr map
+ compositeParent.getAttributes().put(key, value);
+ }
+
} else {
// In the case of full state saving, the compositeParent won't
// have the facet to be relocated as its own - it will have already
@@ -187,7 +197,7 @@
throwRequiredException(ctx, facetName, compositeParent);
}
}
-
+
}
Index: jsf-ri/src/main/java/com/sun/faces/facelets/tag/composite/InsertChildrenHandler.java
===================================================================
--- jsf-ri/src/main/java/com/sun/faces/facelets/tag/composite/InsertChildrenHandler.java (revision 8549)
+++ jsf-ri/src/main/java/com/sun/faces/facelets/tag/composite/InsertChildrenHandler.java (working copy)
@@ -38,6 +38,7 @@
package com.sun.faces.facelets.tag.composite;
import com.sun.faces.facelets.tag.TagHandlerImpl;
+import com.sun.faces.facelets.tag.jsf.ComponentSupport;
import com.sun.faces.util.FacesLogger;
import javax.faces.component.UIComponent;
@@ -168,7 +169,19 @@
List<UIComponent> compositeChildren = compositeParent.getChildren();
List<UIComponent> parentChildren = component.getChildren();
+
+ //store the new parent's info per child in the old parent's attr map
+ //<child id, new parent>
+ for (UIComponent c : compositeChildren) {
+ String key = (String)c.getAttributes().get(ComponentSupport.MARK_CREATED);
+ String value = component.getId();
+ if (key != null && value != null) {
+ compositeParent.getAttributes().put(key, value);
+ }
+ }
+
parentChildren.addAll(getIdx(), compositeChildren);
+
}