Composition is not rendered in Richfaces tabPanel

北城以北 提交于 2019-12-24 07:06:39

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/20967953/composition-is-not-rendered-in-richfaces-tabpanel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!