protected void encodeCell( FacesContext context, DataTable table, UIColumn column, String clientId, boolean selected) throws IOException { if (!column.isRendered()) { return; } ResponseWriter writer = context.getResponseWriter(); boolean selectionEnabled = column.getSelectionMode() != null; String style = column.getStyle(); String styleClass = selectionEnabled ? DataTable.SELECTION_COLUMN_CLASS : (column.getCellEditor() != null) ? DataTable.EDITABLE_COLUMN_CLASS : null; String userStyleClass = column.getStyleClass(); styleClass = userStyleClass == null ? styleClass : (styleClass == null) ? userStyleClass : styleClass + " " + userStyleClass; writer.startElement("td", null); writer.writeAttribute("role", "gridcell", null); if (style != null) writer.writeAttribute("style", style, null); if (styleClass != null) writer.writeAttribute("class", styleClass, null); if (selectionEnabled) encodeColumnSelection(context, table, clientId, column, selected); else column.encodeAll(context); writer.endElement("td"); }
public void encode(FacesContext context, DataTableRenderer renderer, DataTable table) throws IOException { ResponseWriter writer = context.getResponseWriter(); Map<String, String> params = context.getExternalContext().getRequestParameterMap(); String clientId = table.getClientId(context); String[] cellInfo = params.get(clientId + "_cellInfo").split(","); int rowIndex = Integer.parseInt(cellInfo[0]); int cellIndex = Integer.parseInt(cellInfo[1]); int i = -1; UIColumn column = null; for (UIColumn col : table.getColumns()) { if (col.isRendered()) { i++; if (i == cellIndex) { column = col; break; } } } table.setRowIndex(rowIndex); if (column.isDynamic()) { DynamicColumn dynamicColumn = (DynamicColumn) column; dynamicColumn.applyStatelessModel(); } if (table.isCellEditEscapeRequest(context)) { column.getCellEditor().getFacet("input").encodeAll(context); } else { column.getCellEditor().getFacet("output").encodeAll(context); } if (column.isDynamic()) { ((DynamicColumn) column).cleanStatelessModel(); } }