• Post Reply Bookmark Topic Watch Topic
  • New Topic

how t to prevent extra blank row using h:datatable using jsf  RSS feed

 
Mintu Mmazumder
Greenhorn
Posts: 10
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one xhtml file. Extract of the file is below

<h:panelGrid columnClasses= …. styleClass= ….>
<h:column>
<h:outputText value="ColumnA" />
</h:column>
<h:column>
<h:outputText value="ColumnB" />
</h:column>
………………..
Few more columns here
…………………
</h:panelGrid>
<h:dataTable styleClass="borderlessTable"
columnClasses=…….
headerClass=….. rowClasses="………., …………"
value=”…….." var="……." >
<h:column>
<h:outputText value="#{value of ColumnA}" escape="false" >
</h:outputText>
</h:column>
<h:column>
<h:outputText value="#{value of ColumnB}" escape="false" >
</h:outputText>
</h:column>

…………………….

Values of few columns

……………………

</h:dataTable>

</h:panelGroup>

In CSS file

.borderlessTable {
width: 100%;
border: 0;
margin: 0px;
padding: 0px;
font: 12pt Times New Roman, Arial, sans-serif;
background-color: #FFFFFF;
overflow:scroll;
height: 0%;
}

The problem statement is below.
If I do “view source” on the screen
I can see a blank tr and td gets generated in between header and table if there is no row/record in the table. But if I have at least one row/record in the table, then I don’t see any any tr and td.

Can anyone tell me why blank <tr> and <td> gets generated and how can it be removed. Because it creates a blank space between header and table if there is no record in the table.
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Useful info: We have a "Code" button on our message editor. It inserts code tags into your posting that can be used to wrap sample Java code, XML, and other pre-formatted text and make them easier to read.

I'm not sure I understood clearly, but I can make a few guesses. You talked about a header for your table (and you have a headerClass attribute), but no actual header facet in your table layout. Which makes it appear that you are using the panelGrid to generate a visual header instead of making it actually part of the dataTable.

An empty dataTable MUST consist of at least one empty row/column or it won't meet the minimum requirements for an HTML table. To hide the table entirely, you'd need a "rendered="false"" value on the dataTable.
 
Mintu Mmazumder
Greenhorn
Posts: 10
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the response ,Tim. I fixed it in the following way.
1. I used the rendered attribute here to evaluate if there is any record in the table
2. If the table is empty then don’t need show the table
3. If the table has at least one record then show the table
4. To do the first step, I used an attribute from bean which returns false if no records found
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what I do as well.

Some extended versions of the dataTable (such as the Richfaces rich dataTable) have an option to display a table header along with a row with a message such as "No Data" in the empty table. Basic JSF lacks that ability, though.
 
Mintu Mmazumder
Greenhorn
Posts: 10
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct. Thanks for the help.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!