JSF h:dataTable creates single empty cell when no records

vimaxvimaxbbox

New Member
Is there any way to prevent an h:datatable from creating an empty row when the backing value is empty?More specifically:I have a collection of data to be displayed in 3 columns in an h:dataTable with column headers. The thead always needs to be displayed, regardless of if there are elements in the list. This works fine, but when no elements are in the list, a single, empty row/cell is created in the tbody. Is there a way to prevent this? Thanks!Sample method from backing bean. For testing i've tried returning both null or an empty list. Same result for both.\[code\] public List<LocationsDecorator> getLocations() { return null;}\[/code\]JSF fragment:\[code\]<h:dataTable styleClass="locations" id="locations1" var="nearestLoc" value="http://stackoverflow.com/questions/13713252/#{confirmationBean.locations}"> <h:column> <!-- column header --> <f:facet name="header">Address</f:facet> <!-- row record --> #{nearestLoc.adddress} </h:column> <h:column> <!-- column header --> <f:facet name="header">Distance</f:facet> <!-- row record --> #{nearestLoc.distance} </h:column> <h:column> <!-- column header --> <f:facet name="header">Hours of Operation</f:facet> <!-- row record --> <h:dataTable styleClass="locations" var="data" value="http://stackoverflow.com/questions/13713252/#{nearestLoc.hoursOfOperation}"> <h:column> #{data} </h:column> </h:dataTable> </h:column></h:dataTable>\[/code\]Resulting HTML(The "\[code\]<tr><td></td></tr>\[/code\]" in the tbody is the problem):\[code\]<table id="contact:locations1" class="locations"><thead><tr><th scope="col">Address</th><th scope="col">Distance</th><th scope="col">Hours of Operation</th></tr></thead><tbody><tr><td></td></tr></tbody></table>\[/code\]
 
Back
Top