2012-10-04 51 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.