//
// 1. Gather all the data we need to render
//
final RowData rowData = tContext.getRowData();
boolean isEmptyTable = rowData.isEmptyTable();
final UIComponent detail = tContext.getDetail();
//
// 2. Render the top / column header
//
_renderTableHeader(context, arc, tContext, component);
// render the column header
if (tContext.hasColumnHeaders())
_renderColumnHeader(context, arc, tContext, component);
//
// 3. Render each row
//
ColumnData colData = tContext.getColumnData();
final RenderStage renderStage = tContext.getRenderStage();
renderStage.setStage(RenderStage.DATA_STAGE);
// use the special response writer in our data section that
// defaults data cells with no data to <br>
//tContext.setDataResponseWriterUsed(true);
int physicalCol = 0;
if (isEmptyTable)
{
writer.startElement("tr", null);
if (tContext.hasSelection())
{
colData.setColumnIndex(physicalCol++, ColumnData.SPECIAL_COLUMN_INDEX);
_renderEmptyCell(context, arc, tContext, true, null);
}
// render detail control (hide/show for the row)
if (detail != null)
{
colData.setColumnIndex(physicalCol++, ColumnData.SPECIAL_COLUMN_INDEX);
_renderEmptyCell(context, arc, tContext, true, null);
}
int objectNameColumnIndex = colData.getObjectNameColumnIndex();
if (objectNameColumnIndex < physicalCol)
objectNameColumnIndex = physicalCol;
for (int columns = colData.getColumnCount(); physicalCol < columns;)
{
colData.setColumnIndex(physicalCol, ColumnData.SPECIAL_COLUMN_INDEX);
final Object emptyText;
if (objectNameColumnIndex == physicalCol)
{
emptyText = getEmptyText(bean);
}
else
{
emptyText = null;
}
_renderEmptyCell(context, arc, tContext, false, //isSelect
emptyText);
physicalCol++;
}
writer.endElement("tr");
}
else //not an empty table
{
TableUtils.RowLoop loop = new TableUtils.RowLoop()
{
@Override
protected void processRowImpl(FacesContext fc, CollectionComponent tableBase)
throws IOException
{
ResponseWriter rw = fc.getResponseWriter();
// compute all the rowSpans for the current row:
rowData.setCurrentRowSpan(-1); //reset
renderStage.setStage(RenderStage.START_ROW_STAGE);
renderSingleRow(fc, arc, tContext, component);
renderStage.setStage(RenderStage.DATA_STAGE);
// render each of the individual rows in the rowSpan:
for(int i=0, sz=rowData.getCurrentRowSpan(); i<sz; i++)
{
// start the row
rw.startElement("tr", null);
renderSingleRow(fc, arc, tContext, component);
rowData.incCurrentSubRow();
// end the row
rw.endElement("tr");
}
// if necessary, render a detail row