JSF h: dataTable tworzy pojedynczą pustą komórkę, gdy brak rekordów
Czy istnieje sposób, aby zapobiec utworzeniu pustego wiersza przez h: datatable, gdy wartość kopii zapasowej jest pusta? Dokładniej: mam kolekcję danych do wyświetlenia w 3 kolumnach w h: dataTable z nagłówkami kolumn. Thead zawsze musi być wyświetlany, niezależnie od tego, czy na liście są elementy. Działa to dobrze, ale gdy na liście nie ma żadnych elementów, w tekście tworzony jest pojedynczy pusty wiersz / komórka. Czy istnieje sposób, aby temu zapobiec?
Dzięki!
Metoda przykładowa z fasoli podkładowej. Do testowania próbowałem zwrócić zarówno wartość null, jak i pustą listę. Ten sam wynik dla obu.
public List<LocationsDecorator> getLocations() {
return null;
}
Fragment JSF:
<h:dataTable styleClass="locations" id="locations1"
var="nearestLoc" value="#{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="#{nearestLoc.hoursOfOperation}">
<h:column>
#{data}
</h:column>
</h:dataTable>
</h:column>
</h:dataTable>
Wynikowy HTML (The ”<tr><td></td></tr>
„na ziemi jest problem”:
<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>