• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

datatable renders empty rows

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I am pretty sure I know my answer on this one, but I will put it out here in hopes someone has a different response.

I have a scenario where I am displaying a list of categorized items. For each category I am displaying a tab. Within each tab is a datatable that lists the items for that specific category. In the datatable I only render the column if the vehicleCategoryID matches the category for the tab selected. So if "Cars" has a categoryID of 1 and "Trucks" has a categoryID of 2 then when the first tab is selected I only render the column if the categoryID is 1. Notice I am using a single datatable here as it is much easier to create, manipulate, and read instead of the 7 different datatables I would have to create otherwise. At first glance this works great. When I click on the "Cars" tab I only see car models and when I click on the "Trucks" tab I see only truck models. The problem with this though is I noticed some odd spacing between some of the rows in the tables. Not horrible, but enough to throw the ui look off. Upon further inspection of the page source I found that the spacing between rows was caused by empty additional <tr> tags being added without any matching <td> tags. This is when I realized that even though the columns were not being rendered due to how I specified the rendered attribute, the rows were still being rendered. I suppose I made a mistake in assuming that if no columns were rendered, the rows would not be rendered either. See the pseudo-code below for an example of what I am talking about.

My question is obviously has anyone easily worked around this issue and gotten the <tr> tags to not render. I was hoping for an easy solution as I need to deploy this application shortly, but I am open to any responses on the matter.



For example pseudo-code:

(datamodel "vehicleDataModel" contains all data for both "Cars" and "Trucks")
...
<tab value="Cars">
<datatable value="backing.vehiclesDataModel" var="vehicleData">
<column rendered="#{vehicleData.vehicleCategoryID==1}">
<h:outputText value="#{vehicleData.vehicleModel}" />
</column>
</datatable>
</tab>
<tab value="Trucks">
<datatable value="backing.vehiclesDataModel" var="vehicleData">
<column rendered="#{vehicleData.vehicleCategoryID==2}">
<h:outputText value="#{vehicleData.vehicleModel}" />
</column>
</datatable>
</tab>
...



Thanks Again,

Demian
 
Demian Seiler
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, well I will respond to my own post.

I happened to update from the richfaces 3.0.1 to richfaces 3.1.0 to utilize a new component and as I was testing I noticed my tables appeared to be rendering correctly.

So there you have it in case anyone has this issue.

Demian
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Demian, i am currently facing same problem which you have faced. Actually, i am also some bit new for this JSF. Can you tell me which component i should use to remove those empty rows from the table.

As of now, I have put a rendered condition at column level but it is anyway rendering empty rows for which the rendered column condision is false.

Please reply as soon as possible.
Thanks in advance.
 
Demian Seiler
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

The only change I made to get this to work was to download the following versions of the rich faces jars.

richfaces-api-3.1.0.jar
richfaces-impl-3.1.0.jar
richfaces-ui-3.1.0.jar

Other than that I did nothing different. I think this was just a bug in the version of the richfaces datatable.

Google on "download richfaces" and you should find the jars

Sorry if this doesn't help.

Demian
 
Gaurang Panchal
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anybody have any idea?
I am still waiting...
 
Gaurang Panchal
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Finally i have solved my problem...

My problem was that, i had problem of unnecessary empty rows in the h:dataTable. The unnecessary <tr> tag has been added without <td> tag inside while i have seen the HTML code of JSF page. It was happening due to conditional rendering of column inside data table.

To solve this i have removed the conditional rendering of the column and put "first" and "rows" data members at backing bean. While navigation i set their values and then in JSF page i have put h:dataTable with both of its attribute "first" and "rows" assigned to their specific values in the backing bean.
 
and POOF! You're gone! But look, this tiny ad is still here:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic