Empty t:dataTable might be rendering invalid HTML?

I use Tomahawk 1.1.8 and I'm trying to build/render a dataTable even if it's empty. (rendered="true" as requirement)

Considering our Bean provides an empty list (no rows to be displayed by t:dataTable). Why does Tomahawks' t:dataTable just render following "invalid" HTML even if we have a header providing more than one column:


The JSF Code for the t:dataTable is as usual:

<t:dataTable value="#{bean.list}" var="dataItem"> <h:column> <f:facet name="header"> <h:outputText value="A"/> </f:facet> <h:outputText value="#{dataItem.a}" /> </h:column> <h:column> <f:facet name="header"> <h:outputText value="B"/> </f:facet> <h:outputText value="#{dataItem.b}" /> </h:column> <h:column> <f:facet name="header"> <h:outputText value="C"/> </f:facet> <h:outputText value="#{dataItem.c}" /> </h:column> </t:dataTable>

In contrast, JSF h:dataTable renders "better" by just omitting the complete tr tag (=even if I'm not sure if this might be "invalid" HTML, too):


My problem with this is the absence of inner table top borders/rules when css "border-collapse:collapse;" is active.

I prepared two HTML examples. One describing the actual fact and the other a possible solution how Tomahawk possibly could fix it:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>less td than th in one row</title> <style type="text/css" media="screen"> table { border-collapse: collapse; } th, td { border:1px solid #716F70; } </style> </head> <body> less td than th in one row: borders in FF3.x e.g. are rendered just for two table body cells: <br /> <table border="1"> <tr> <th>1</th> <th>2</th> <th>3</th> <th>4</th> <th>5</th> <th>6</th> </tr> <tr> <td>cell1</td> <td>cell2</td> <td>cell3</td> <td>cell4</td> <td>cell5</td> <td>cell6</td> </tr> <tr> <td>cell1</td> <td/> </tr> </table> </body> </html>

...now how it would be better with colspan:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>less td than th in one row: border with colspan ok</title> <style type="text/css" media="screen"> table { border-collapse: collapse; } th, td { border:1px solid #716F70; } </style> </head> <body> less td than th in one row: border (top) rendered for complete row, because of &lt;td colspan="5"/&gt; in cell 2 of row 2: <br /> <table border="1"> <tr> <th>1</th> <th>2</th> <th>3</th> <th>4</th> <th>5</th> <th>6</th> </tr> <tr> <td>cell1</td> <td>cell2</td> <td>cell3</td> <td>cell4</td> <td>cell5</td> <td>cell6</td> </tr> <tr> <td>cell1</td> <td colspan="5"/> </tr> </table> </body> </html>

A colspan over all cells of a row might be the best, I think.

Some Browsers like IE or Opera don't mind, however Firefox does and I can take this point, too.

Are there any workarounds or patterns how to get the best result out of this? I ask, because I might be missing a technique.


-------------Problems Reply------------

I know this is an old question, but I encountered a similar problem and the approach I used to solve this was by checking if the data exists by using empty in the following way.

bodyStyleClass = "#{empty bean.list ? 'hidden' : ''}"

The CSS class 'hidden' then gets applied to the body of the table, so you're left with just the table column headers and the display problem goes away. Your CSS should look like this:

.hidden {
display: none;

Hope this helps anyone encountering this in the future. This stack overflow question may also be of use to you, as well as the reference on http://myfaces.apache.org/tomahawk-project/tomahawk/tagdoc/t_dataTable.html if you wish to do something else other than apply a class to the body level of your table.

Category:jsf Views:0 Time:2010-06-09

Related post

  • JSF inner datatable not respecting rendered condition of outer table 2010-03-26

    <h:dataTable cellpadding="0" cellspacing="0" styleClass="list_table" id="OuterItems" value="#{valueList.values}" var="item" border="0"> <h:column rendered="#{item.typeA}"> <h:dataTable cellpadding="0" cellspacing="0" styleClass="list_t

  • The troubleshooter is rendered invalid and cannot be run 2015-01-08

    My system idle process is runnung up to 100% i have win 7 x64 3GB ram, its always running at this, also when i go to run the auto fix it, programm it downloads but then has error saying The troubleshooter is rendered invalid and cannot be run, what i

  • JSF: Empty nested dataTable 2012-03-19

    I'm writing my own implementation of JMX console for JBoss 6.1 based on JSF. There is a part of code of managed bean: @ManagedBean @SessionScoped public class InspectionBean implements Serializable { private MBeanInfo data; private List<OperationW

  • Paypal IPN returns empty string instead of "VERIFIED" or "INVALID" 2011-02-06

    In real (not Sandbox) environment Paypal IPN sends POST data with payment_status = Completed. But when I tried to get transaction confirmation from Paypal (using CURL) I receive an empty string (not "VERIFIED" or "INVALID"). CURL does not return any

  • PRIMEFACES: empty p:dataTable (binding problem) 2011-05-22

    I've simply changed working JSF h:dataTable to p:dataTable, but it's empty. Without headers, one empty row. I've installed primefaces-3.0.M1.jar to my project. UPDATE: if I remove binding, dataTable is working properly, but without advantages of Html

  • Primefaces datatable partial page rendering does not work with 2012-01-16

    I have a p:fileUpload which works fine. But I need a partial page rendering of a p:datatable after a new file was uploaded. The datatable shows the current files. The strange this is, once I upload one file, the table is rerendered, showing one recor

  • TemplateSyntaxError at /admin/ Caught SyntaxError while rendering: invalid syntax 2011-10-26

    I have an app names blogspot and when ever I add the urls related to this app, into the project urls.py file I get the above given error. The code for the urls.py file for the blogspot app is from django.conf.urls.defaults import * from blogspot.mode

  • How do I display a message if a jsf datatable is empty? 2009-12-31

    Using JSF1.2, if my datatable binding returns no rows I want to display a message saying so. How do I do that? And for extra points - how do I hide the table completly if it's empty? Thanks. --------------Solutions------------- Make use of the render

  • JSF: Empty space caused by rendered attribute 2011-05-26

    How can I get rid of the empty space by components not rendered via rendered attribute? I want to display a list of objects in a dataTable and sort them by a property they have. I do it likes this: view plaincopy to clipboardprint? <t:dataTable va

  • Why is my rich:dataTable not rendering? 2012-03-21

    I can not figure out why my rich:dataTable is not rendering. I am using JSF 2 and Richfaces 4. URL is http://localhost:8080/contacts-as7/me2.jsf?sitecode=0Z56, but it behaves the same without the sitecode parameter. Here is the view <!DOCTYPE html

  • Although rendered="false", content of a h:dataTable is always evaluated 2011-01-23

    I have got a problem with the HtmlDataTable of JSF 2.0. On my web page, i have got a h:dataTable and some other content, which should only be rendered if the user is logged in. The content of the HtmlDataTable is loaded from a database. Although the

  • My stored procedure returns something, but sqlDataAdapter.Fill leaves datatable empty 2011-04-01

    Something stopped working in my application. I tested my stored procedure and it does return 3 rows (too big to repost here). At the output in Visual Studio it says afterwards: (1 row(s) affected) (3 row(s) returned) @RETURN_VALUE = 0 Finished runnin

  • Custom Django CheckboxSelectMultiple widget rendered as an empty list 2011-10-26

    I am trying to create a CheckboxSelectMultiple widget that lists all the content types of my project. I started by using the base widget when defining a MultipleChoiceField field in a ModelForm and it worked fine. I would like now to make it a custom

  • JSF2: why does empty test in rendered of panelGroup in composite prevent action from being called? 2012-03-07

    I am having problems getting an action of a managed bean to be called when certain other JSF elements from custom composite components are present in the same page as the h:commandButton that submits the h:form. I can narrow down the page elements th

  • JSF Extend a base datatable by including an extra column from another page 2010-02-09

    I have a base datatable with 20 columns which is used by all reports...Some reports add additional columns, is there a way to put the code for the extra column in a separate JSF page and reference this some how? e.g. datatable.jsp <%@ taglib uri="

  • jQuery: DataTables query 2011-04-19

    I am using jQuery Datatable plugin for rendering a table as jQuery DataTable. I am not using any server side calls for fetching table row details. I am generating the table HTML using jQuery from the information available on the page the user is curr

  • How does reRender behave if table is not rendered 2012-03-01

    I was just implementing a crude functionality using jsf+richfaces and came across this situation, so putting this to the open forum for some answers. I have a text field and rich:dataTable inside a form. When value changes in textField, table data is

  • Compare two DataTables to determine rows in one but not the other 2008-10-02

    I have two DataTables, A and B, produced from CSV files. I need to be able to check which rows exist in B that do not exist in A. Is there a way to do some sort of query to show the different rows or would I have to iterate through each row on each D

  • Dojo Table not Rendering in IE6 2009-07-30

    I'm trying to use Dojo (1.3) checkBoxes to make columns appear/hide in a Dojo Grid that's displayed below the checkBoxes. I got that functionality to work fine, but I wanted to organize my checkBoxes a little better. So I tried putting them in a tabl

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.753 (s). 11 q(s)