12

I use <f:facet> to create a table header and I want a symbol beside it. However, it doesn't seem to work well. The symbol is not rendered.

JSF:

<h:column id="subject_column">
  <f:facet name="header">
    <h:commandLink value="Subject" id="sort_by_subjects"
                   action="#{xxx.sort}">
      <f:param id="sortBySubject" name="sortBy" value="SUBJECT"/>
    </h:commandLink>
    <span>${isAscending}</span>
  </f:facet>
  <h:outputText value="#{email.emailSubject}"/>
</h:column>

${isAscending} contains the arrow symbol and represents the order. I would like to show it beside <h:commandLink>.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Roger.H
  • 343
  • 1
  • 4
  • 18

2 Answers2

25

The <f:facet> can have only one child. Wrap multiple children in a <h:panelGroup>.

<h:column>
    <f:facet name="header">
        <h:panelGroup>
            <h:commandLink ... />
            <h:outputText ... />
        </h:panelGroup>
    </f:facet>
    ...
</h:column>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I'd like to mention that at least in Mojarra 2.2.5 that is not so. You can have multiple children in a `f:facet`, and Mojarra creates an implicit wrapping `UIPanel` for them. This does go against JSF spec. – Vsevolod Golovanov Jul 03 '14 at 17:10
  • I've noticed this is not always the case with PrimeFaces components. They seem to sometime allow multiple children on a facet – Kukeltje Feb 25 '16 at 09:05
  • @Kukeltje: it's indeed fixed somewhere between March 2012 and now, I only can't tell yet when. Perhaps later and then I'll update the answer. – BalusC Feb 25 '16 at 09:07
0

The <f:facet> can have only one child. Wrap it in a <h:panelGroup> or <h:panelGrid>.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47