我有以下 <h:panelGrid>
:
<h:panelGrid columns="2" id="panelGrid" >
<!-- heading -->
<f:facet name="header">
User Details
</f:facet>
<h:outputLabel value="#{bundle.ViewUserdetailsLabel_id}"/>
<!-- adding in a small effect here that will fade a message when a user hovers over the id number or username -->
<h:outputLink id="id1" value="#">
<h:outputText id="id" value="#{userdetailsController.selected.id}" title="#{bundle.ViewUserdetailsTitle_id}"/>
</h:outputLink>
<p:tooltip for="id" value="This is your I.D. Number" showEffect="fade" hideEffect="fade" />
<h:outputText value="#{bundle.ViewUserdetailsLabel_username}"/>
<h:outputLink id="username1" value="#">
<h:outputText id="username" value="#{userdetailsController.selected.username}" title="#{bundle.ViewUserdetailsTitle_username}"/>
</h:outputLink>
<p:tooltip for="username" value="Your registered username, this can be changed" showEffect="fade" hideEffect="fade" />
<f:facet name="footer"></f:facet>
</h:panelGrid>
我希望它显示为
User Details Id: 500 Username: zzzzzzzz
但是,它显示的是一些空单元格:
User Details Id: 500 Username: zzzzzzzz
当我使用 <p:panelGrid>
时同样的问题仍然存在而不是 <h:panelGrid>
.这是怎么引起的,我该如何解决?
最佳答案
在面板网格中,每个直接子组件都算作一个表格单元格。
那些<!-- heading -->
和 <!-- adding ... -->
评论行将每个都算作一个 child 。因此,这些也算作一个单独的表格单元格。
要解决它,只需通过以下命令告诉 Facelets 在 View 构建期间跳过所有注释 web.xml
条目:
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
然后是 <p:tooltip>
即使它不代表任何直接内容,它也算作一个表格单元格。您需要将工具提示及其目标组件包装在 <h:panelGroup>
中以便它代表单个表格单元格(此外,您也可以选择将评论放在那里)。
<h:outputLabel value="#{bundle.ViewUserdetailsLabel_id}"/>
<h:panelGroup>
<!-- adding in a small effect here that will fade a message when a user hovers over the id number or username -->
<h:outputLink id="id1" value="#">
<h:outputText id="id" value="#{userdetailsController.selected.id}" title="#{bundle.ViewUserdetailsTitle_id}"/>
</h:outputLink>
<p:tooltip for="id" value="This is your I.D. Number" showEffect="fade" hideEffect="fade" />
</h:panelGroup>
<h:outputText value="#{bundle.ViewUserdetailsLabel_username}"/>
<h:panelGroup>
<h:outputLink id="username1" value="#">
<h:outputText id="username" value="#{userdetailsController.selected.username}" title="#{bundle.ViewUserdetailsTitle_username}"/>
</h:outputLink>
<p:tooltip for="username" value="Your registered username, this can be changed" showEffect="fade" hideEffect="fade" />
</h:panelGroup>
关于jsf - h :panelGrid renders empty table cells,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20070402/