When creating a datatable with Primefaces, I want to create a button on both the header and footer facets, but without duplicating code.
Think of having the following header facet on a <p:dataTable/>
element:
<f:facet name="header">
<p:commandButton value="Preview" icon="pi pi-search" update="@form:dPreview"
oncomplete="PF('wvdPreview').show()"
/>
</f:facet>
How could I add the same code in another facet (let's say, name="footer"
) without duplicating the code?
I searched some options on the Internet, but only found the option to duplicate the header's code or to create a brand new component, and I'm not expecting to apply any of those approaches unless there's no other way.