While analyzing the state issue
JAVASERVERFACES-2040 I found out that the tree creation is broken on postback when using <cc:insertChildren> directly in <cc:implementation>.
The relevant composite components will look like this:
What will happen on postback:
1.) The view will be created fine in restoreView phase. This includes the invocation of com.sun.faces.facelets.tag.composite.InsertChildrenHandler.RelocateChildrenListener that will move the childs of the composite component (UINamingContainer) to the implicit panel of the composite component implementation.
2.) In renderView phase the facelets tree is applied a second time. But this time com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.ComponentTagHandlerDelegateImpl will not find the already existing childs of the composite component because they were relocated. The relevant method com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.findReparentedComponent() will never be called in this case.
As a result new child components will be created (with invalid state).
If insertChildren is nested inside a component the relocating code will work as expected. The working components will look like this: