title: Empty h:dataTable in JSF renders empty row with invalid number of columns?
body: <p>I have the following JSF code which renders a table from a Bean which might be empty</p>
  
  <pre><code>&lt;h:dataTable value="#{recController.currentRecList}" var="rec" styleClass="display" id="rec"&gt;
     &lt;h:column&gt;
       &lt;f:facet name="header"&gt;
            &lt;h:outputText value="#{msg['rec.name']}"/&gt;
       &lt;/f:facet&gt;
       #{rec.name}
     &lt;/h:column&gt;
     &lt;h:column&gt;
       &lt;f:facet name="header"&gt;
          &lt;h:outputText value="#{msg['rec.notes']}"/&gt;
       &lt;/f:facet&gt;
       #{rec.notes}
    &lt;/h:column&gt;
  &lt;/h:dataTable&gt;
  </code></pre>
  
  <p>problem is the above code renders the following HTML:</p>
  
  <pre><code>&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;
  </code></pre>
  
  <p>The above is wrong because it should render:</p>
  
  <pre><code>&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;
  </code></pre>
  
  <p>where the number of columns is two and not one! but even better it should render just:</p>
  
  <pre><code>&lt;tbody&gt;&lt;/tbody&gt;
  </code></pre>
  
  <p>So that DataTables js script recognizes there's no rows and shows a nice "Empty table".<br>
  Currently DataTables js script returns an error:</p>
  
  <pre><code>DataTables warning: table id=rec - Requested unknown parameter '1' for row 0. 
  For more information about this error, please see http://datatables.net/tn/4
  </code></pre>
  
  <p>of course because it sees a row but with an incorrect number of columns.</p>
  
  <p><img src="https://i.stack.imgur.com/inhWl.png" alt="warning datatables"></p>
  
  <p>Now using Primefaces p:dataTable produces even more boilerplate html code because the table is buried inside several div's and when an empty result is returned it produces a:</p>
  
  <pre><code>&lt;tr class="ui-widget-content ui-datatable-empty-message"&gt;
  &lt;td class=" " colspan="4"&gt;No records found.&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>So again DataTables js (<a href="http://datatables.net/" rel="nofollow noreferrer">http://datatables.net/</a>) finds a wrong number of columns.
  Is there a way to tell primefaces what html code to output when no result is found?</p>