2012-10-04 48 views
0

绘图表意味着JSF 该表只包含标题。经过渲染仍然是一个空白标签TBODY渲染后jsf - 空tbody元素

JSF:

<h:dataTable> 
     <h:column> 
      <f:facet name="header"> 
       <h:outputText value="col1" /> 
      </f:facet> 
      </h:column> 
      <h:column> 
      <f:facet name="header"> 
       <h:outputText value="col2" /> 
      </f:facet> 
      </h:column> 
    </h:dataTable> 

HTML结果:

<table> 
    <thead> 
    <tr> 
     <th> 
     <span>col1</span> 
     </th> 
     <th> 
     <span>col2</span> 
     </th> 
    </tr> 
    </thead> 
    <tbody> </tbody> 
</table> 

如何编写,将不创建一个空的TBODY元素

回答

2

有JSF代码你的dataTable没有错。你定义的唯一的东西是:

  • 我想要一个表;
  • 我希望表格有2列;
  • 我想要第一列有标题“col1”;
  • 我希望第二列有标题“col2”;

这正是JSF为您呈现的。您没有将任何数据传递给dataTable。您必须使用value属性并传递一个列表。

BalusC has an old article, but still usefull, about Using datatables.