faces icon indicating copy to clipboard operation
faces copied to clipboard

Allow passthrough on facets

Open tandraschko opened this issue 1 year ago • 3 comments

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

  1. the facet is null when there is no content defined
  2. the facet is NOT null when there is no content but passthrough attributes
  3. passthrough attributes are available on the facet

@BalusC any thoughts?

tandraschko avatar Apr 07 '25 11:04 tandraschko

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

tandraschko avatar Apr 07 '25 11:04 tandraschko

+1, thank you

lprimak avatar Apr 13 '25 22:04 lprimak

Great proposal, +1.

BalusC avatar Apr 15 '25 09:04 BalusC

Created PR for Mojarra; only still need to look how to fit in the spec and create an IT for TCK.

BalusC avatar Jan 05 '26 21:01 BalusC