JSF h:在f:facet中的panelGroup不起作用

时间:2014-08-12 04:31:56

标签: jsf primefaces datatable

我已将此问题提取到一个简单的场景中。显然我可以解决这个问题,但对于解释可能是什么以及为什么这不起作用很好奇。

使用h:dataTable作为示例,如果我将<h:panelGroup>放在表的<f:facet>之一中,<h:panelGroup>内的内容不会显示,而我不明白为什么。

这是一个使用Spring,Hibernate和Primefaces与JSF2和facelets一起在Tomcat上运行的项目,但这似乎是股票标准的JSF行为?

在下面的例子中,h:panelGroup的内容都没有显示,除非我在h:panelGroup之前添加一个元素(例如某些文本)然后它会显示出来吗?

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

<f:view contentType="text/html">
    <h:head>
        <f:facet name="first">
            <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
            <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
            <title>-- Nothing --</title>
        </f:facet>

    </h:head>

    <h:body>
        <h:form id="nothingForm">
        <h:dataTable id="nothingData" value="#{null}" var="item">
           <h:column>
               <f:facet name="header"> col1 </f:facet>
               things
           </h:column>
            <h:column>
                <f:facet name="header">
                    <h:panelGroup id="headerGroup" rendered="#{true}">
                    crappo
                    </h:panelGroup>
                    col2
                </f:facet>
                stuff
            </h:column>
            <f:facet name="footer">
                <h:panelGroup id="footerGroup" rendered="#{true}">
                    crappo
                    <h:commandButton id="btn1" value="Button 1" />
                </h:panelGroup>
                <h:commandButton id="btn2" value="Button 2" />
            </f:facet>
        </h:dataTable>
        </h:form>
    </h:body>
</f:view>
</html>

谢谢你的期待!

1 个答案:

答案 0 :(得分:0)

<f:facet>必须包含一个节点,而您的<h:panelGroup>和文字&#34; col2&#34;是两个节点。 尝试移动<h:panelGroup> ...

内的文字
相关问题