protected void encodeRowExpansion(FacesContext context, DataTable table) throws IOException { ResponseWriter writer = context.getResponseWriter(); Map<String, String> params = context.getExternalContext().getRequestParameterMap(); int expandedRowIndex = Integer.parseInt(params.get(table.getClientId(context) + "_expandedRowIndex")); String rowIndexVar = table.getRowIndexVar(); table.setRowIndex(expandedRowIndex); if (rowIndexVar != null) { context.getExternalContext().getRequestMap().put(rowIndexVar, expandedRowIndex); } writer.startElement("tr", null); writer.writeAttribute("style", "display:none", null); writer.writeAttribute( "class", DataTable.EXPANDED_ROW_CONTENT_CLASS + " ui-widget-content", null); writer.startElement("td", null); writer.writeAttribute("colspan", table.getColumnsCount(), null); table.getRowExpansion().encodeAll(context); writer.endElement("td"); writer.endElement("tr"); table.setRowIndex(-1); }
public void encodeTbody(FacesContext context, DataTable table, boolean dataOnly) throws IOException { ResponseWriter writer = context.getResponseWriter(); String rowIndexVar = table.getRowIndexVar(); String clientId = table.getClientId(context); String emptyMessage = table.getEmptyMessage(); UIComponent emptyFacet = table.getFacet("emptyMessage"); SubTable subTable = table.getSubTable(); SummaryRow summaryRow = table.getSummaryRow(); if (table.isSelectionEnabled()) { table.findSelectedRowKeys(); } int rows = table.getRows(); int first = table.getFirst(); int rowCount = table.getRowCount(); int rowCountToRender = rows == 0 ? (table.isLiveScroll() ? table.getScrollRows() : rowCount) : rows; boolean hasData = rowCount > 0; if (!dataOnly) { writer.startElement("tbody", null); writer.writeAttribute("id", clientId + "_data", null); writer.writeAttribute("class", DataTable.DATA_CLASS, null); } if (hasData) { for (int i = first; i < (first + rowCountToRender); i++) { if (subTable != null) { encodeSubTable(context, table, subTable, i, rowIndexVar); } else { table.setRowIndex(i); if (!table.isRowAvailable()) { break; } encodeRow(context, table, clientId, i, rowIndexVar); if (summaryRow != null && !isInSameGroup(context, table, i)) { table.setRowIndex(i); // restore encodeSummaryRow(context, table, summaryRow); } } } } else { // Empty message writer.startElement("tr", null); writer.writeAttribute("class", DataTable.EMPTY_MESSAGE_ROW_CLASS, null); writer.startElement("td", null); writer.writeAttribute("colspan", table.getColumnsCount(), null); if (emptyFacet != null) emptyFacet.encodeAll(context); else writer.write(emptyMessage); writer.endElement("td"); writer.endElement("tr"); } if (!dataOnly) { writer.endElement("tbody"); } // Cleanup table.setRowIndex(-1); if (rowIndexVar != null) { context.getExternalContext().getRequestMap().remove(rowIndexVar); } }