Multiple <cc:insertChildren /> in the same composite component
I'm trying to do a composite component with union of a autoComplete and a dataTable. Like this:
<util:myCustomComp ...>
<p:column>#{item.code}</p:column>
<p:column>#{item.name}</p:column>
</util:myCustomComp>
And in CC file:
<p:autoComplete ...>
<cc:insertChildren /> <!-- Show columns only in autocomplete -->
</p:autoComplete>
<p:dataTable ...>
<cc:insertChildren />
</p:dataTable>
But the second isnt rendered, render only the first and skeep (in autoComplete or in dataTable).
<p:autoComplete ... />
<p:dataTable ...>
<cc:insertChildren /> <!-- Show colum开发者_Go百科ns in dataTable -->
</p:dataTable>
Unfortunately, that is not going to work and there are no ways to duplicate components declaratively. Closest what you can get is using <ui:include>
instead.
columns.xhtml
<ui:composition ...>
<p:column>#{item.code}</p:column>
<p:column>#{item.name}</p:column>
</ui:composition>
Main view:
<util:myCustomComp columnsFile="/columns.xhtml" ... />
Composite implementation:
<p:autoComplete ...>
<ui:include src="#{cc.attrs.columnsFile}" />
</p:autoComplete>
<p:dataTable ...>
<ui:include src="#{cc.attrs.columnsFile}" />
</p:dataTable>
(disclaimer: untested, this may break view scoped beans if partial state saving is turned on)
You can use cc:insertChildren in a view only once per composite component, otherwise a duplicate id exception will be thrown. Unfortunately there is no way that could work :-(.
精彩评论