mojarra
mojarra copied to clipboard
Add rendered attribute to f:facet
I have a footer which needs to be displayed conditionally. For the moment I have something like this.
<p:dataTable>
...
<f:facet name="footer">
<h:panelGroup rendered="#{fooBean.footerRendered}">
...
</h:panelGroup>
</f:facet>
</p:dataTable>
This works, but the PrimeFaces data table still generates some HTML div element which leads to some borders drawn. It can be solved by adjusting the PrimeFaces code but it makes sense to add this attribute to the f:facet (since all components have the attributes id, rendered and binding)
Please see this important message regarding community contributions to Mojarra.
https://javaee.groups.io/g/jsf-spec/message/30
Also, please consider joining that group, as that group has taken the place of the old [email protected] mailing list.
Thanks,
Ed Burns
You can use <c:if>
instead to conditionally build the component tree instead of rendered
attribute to conditionally render the HTML output.
<p:dataTable>
...
<c:if test="#{fooBean.footerRendered}">
<f:facet name="footer">
...
</f:facet>
</c:if>
</p:dataTable>
But c:if doesn't include the node into the component tree. So when the footer is required after an ajax update, it is not possible.
True that. As work around you could rebuild the view in the ajax listener method so that the <c:if>
gets re-executed.
Adding rendered
attribute to <f:facet>
isn't really doable. The issue is here more in PrimeFaces DataTableRenderer
. It should actually check if all first children of the <f:facet>
are rendered and if so then only render the <div>
around it.
I already updated PrimeFaces for this, but it seemed me logical that there was also a rendered
attribute on f:facet
.
A disabled
attribute would be more suitable but then PrimeFaces still has to check it as well.