Allow passthrough on facets
Im currently working on a new way to render markup and make it more customizable (even reusing html web-components): for example, to passthrough attributes for a header facet.
<p:dataTable id="table" var="item" value="#{dataTableView.items}" paginator="true" rows="10">
<p:column field="name">
<f:facet name="header" pt:styleClass="my-header">
</f:facet>
<f:facet name="footer" pt:styleClass="my-footer">
Dummy
</f:facet>
</p:column>
<p:column field="country" />
</p:dataTable>
the renderer looks like:
UIComponent header = column.getFacet(ColumnBase.FacetKeys.header);
writer.startElement("p-header", null);
writeAttributeOptional(context, "name", column.getHeaderText());
if (heade r!= null) {
renderPassThruAttributes(context, header);
header.encodeAll(context);
}
writer.endElement("p-header");
UIComponent footer = column.getFacet(ColumnBase.FacetKeys.footer);
writer.startElement("p-footer", null);
writeAttributeOptional(context, "name", column.getFooterText());
if (footer != null) {
renderPassThruAttributes(context, footer);
footer.encodeAll(context);
}
writer.endElement("p-footer");
the header is null here, footer exists but passthrough attributes are not rendered.
we should make sure that
- the facet is null when there is no content defined
- the facet is NOT null when there is no content but passthrough attributes
- passthrough attributes are available on the facet
@BalusC any thoughts?
it may even be possible to make a p:header/p:footer component but we dont need it actually, so reusing facets is fine IMO
+1, thank you
Great proposal, +1.
Created PR for Mojarra; only still need to look how to fit in the spec and create an IT for TCK.