mojarra icon indicating copy to clipboard operation
mojarra copied to clipboard

Add rendered attribute to f:facet

Open rdebusscher opened this issue 6 years ago • 6 comments

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)

rdebusscher avatar Oct 17 '17 08:10 rdebusscher

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

edburns avatar Oct 29 '17 03:10 edburns

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>

BalusC avatar Apr 07 '18 08:04 BalusC

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.

rdebusscher avatar Apr 07 '18 08:04 rdebusscher

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.

BalusC avatar Apr 07 '18 14:04 BalusC

I already updated PrimeFaces for this, but it seemed me logical that there was also a rendered attribute on f:facet.

rdebusscher avatar Apr 07 '18 14:04 rdebusscher

A disabled attribute would be more suitable but then PrimeFaces still has to check it as well.

BalusC avatar Apr 07 '18 15:04 BalusC