Search code examples
javajsfrichfaces

Composition is not rendered in Richfaces tabPanel


I am a user of JSF and Richfaces. I will simplify the code about my question to make things easier. I have a composition named 'mytab.xhtml' defined like following:

<cc:interface>
    <cc:attribute name="header" required="true"/>
</cc:interface>
<cc:implementation>
    <rich:tab id="my-tab" header="#{cc.attrs.header}" >
        <cc:insertChildren />
    </rich:tab>
</cc:implementation>

This composition is used in another xhtml file like following:

<rich:tabPanel id="tp" switchType="ajax" headerPosition="top" >
     <ic:mytab id="tab1" header="header1">
          <h:outputText>content1</h:outputText>
     </ic:mytab>
     <ic:mytab id="tab2" header="header2">
          <h:outputText>content1</h:outputText>
     </ic:mytab>
</rich:tabPanel>

But it is very strange that the tab is not rendered at all. To find the reason, if I add an outputText in the composition definition file like this:

<cc:interface>
    <cc:attribute name="header" required="true"/>
</cc:interface>
<cc:implementation>
        <h:outputText>#{cc.attrs.header}</h:outputText>
    <rich:tab id="my-tab" header="#{cc.attrs.header}" >
        <cc:insertChildren />
    </rich:tab>
</cc:implementation>

The outputText will be rendered, but tab is not rendered.

Or, if I change one of the tab to richfaces tab directly:

<rich:tabPanel id="tp" switchType="ajax" headerPosition="top" >
     <ic:mytab id="tab1" header="header1">
          <h:outputText>content1</h:outputText>
     </ic:mytab>
     <rich:tab id="tab2" header="header2">
          <h:outputText>content1</h:outputText>
     </rich:tab>
</rich:tabPanel>

The first tab will not be rendered, but the second tab will be rendered.

Thank you if you could give me any help.


Solution

  • Composite components are rendered as own UINamingContainer. So between the UITabPanel and the UITab-component now is a UINamingContainer, UITab might not know what to do with it (same problem with datatable, by the way). What you can do is to use a classic facelet tag instead.