【发布时间】:2013-04-18 15:08:08
【问题描述】:
这是我的 jsf:
<h:dataTable class="pretty" value="#{ftController.ftDataModel}" var="item">
<h:column>
<f:facet name="header">
<h:outputText value="Amount"/>
</f:facet>
</h:column>
<h:column >
<f:facet class="right" name="header">
<h:outputText value="Date"/>
</f:facet>
</h:column>
<h:column>
<h:outputLink value="index.jsf"><h:outputText value="#{item.ftType}"/></h:outputLink><br />
<h:outputText class="red" id="amount" value="#{item.amount}"></h:outputText> <h:outputText value=" " /><h:outputText style="font-size:12px" class="gray" value="TL" />
</h:column>
<h:column class="right" >
<h:outputText id="date" value="#{item.date}"></h:outputText>
</h:column>
</h:dataTable>
但是,html 输出是这样的:
<table class="pretty">
<thead>
<tr>
<th scope="col">Amount</th>
<th scope="col">Date</th>
<th scope="col"></th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td><a href="index.jsf" class="ui-link">Person</a><br><span id="j_idt8:j_idt21:0:amount" class="red">34500.6</span> <span class="gray" style="font-size:12px">TL</span></td>
<td><span id="j_idt8:j_idt21:0:date">10/14/2012</span></td>
</tr>
<tr>
<td></td>
<td></td>
<td><a href="index.jsf" class="ui-link">Person</a><br><span id="j_idt8:j_idt21:1:amount" class="red">3444.78</span> <span class="gray" style="font-size:12px">TL</span></td>
<td><span id="j_idt8:j_idt21:1:date">10/15/2012</span></td>
</tr>
</tbody>
</table>
它在金额和日期下为 ex 添加了额外的<th>。它还添加了<td>s 为什么?这里有什么问题?我该如何解决?为什么要添加?
【问题讨论】:
-
您因此面临什么问题?
-
它只是数据表的 HTNL 源。
Column facet==HTML th和column==HTML td -
这是预期的行为。您定义了 4 个
<p:column>。所以它增加了 4 个<td>和 4 个<th>。 -
请务必查看如何在 JSF 数据表中使用 header facet。