public void setupCurrentRowVariables() { if (_evaluatingConverterInsideSetupCurrentRowVariables) { // Prevent endless recursion in the column.getGroupingValueConverter() call (see below). // The grouping-related variables are not required during calculation of // groupingValueConverter, // so we can just skip this method if _evaluatingConverterInsideSetupCurrentRowVariables == // true return; } DataTable dataTable = getDataTable(); Object rowData = dataTable.isRowAvailable() ? dataTable.getRowData() : null; if (!(rowData instanceof GroupHeaderOrFooter)) { Components.setRequestVariable(getColumnHeaderVar(), null); Components.setRequestVariable(getGroupingValueVar(), null); Components.setRequestVariable(getGroupingValueStringVar(), null); return; } GroupHeaderOrFooter row = (GroupHeaderOrFooter) rowData; RowGroup rowGroup = row.getRowGroup(); String columnId = rowGroup.getColumnId(); Column column = (Column) dataTable.getColumnById(columnId); String columnHeader = column.getColumnHeader(); Components.setRequestVariable(getColumnHeaderVar(), columnHeader); Object groupingValue = rowGroup.getGroupingValue(); Components.setRequestVariable(getGroupingValueVar(), groupingValue); Converter groupingValueConverter; _evaluatingConverterInsideSetupCurrentRowVariables = true; // The upcoming getGroupingValueConverter call can invoke table's setRowIndex, which will result // re-entering this setupCurrentRowVariables method, so we should prevent endless recursion // here. try { groupingValueConverter = column.getGroupingValueConverter(); } finally { _evaluatingConverterInsideSetupCurrentRowVariables = false; } FacesContext context = FacesContext.getCurrentInstance(); if (groupingValueConverter == null) { groupingValueConverter = groupingValue != null ? Rendering.getConverterForType(context, groupingValue.getClass()) : null; } String groupingValueStr = groupingValueConverter != null ? groupingValueConverter.getAsString(context, column, groupingValue) : groupingValue != null ? groupingValue.toString() : ""; Components.setRequestVariable(getGroupingValueStringVar(), groupingValueStr); }
public void acceptNewGroupingRules(List<GroupingRule> groupingRules) { if (beforeUpdateValuesPhase) { incomingGroupingRules = groupingRules; return; } DataTable dataTable = getDataTable(); for (GroupingRule sortingRule : groupingRules) { String columnId = sortingRule.getColumnId(); BaseColumn column = dataTable.getColumnById(columnId); if (column == null) throw new IllegalArgumentException("Column by id not found: " + columnId); if (!column.isColumnGroupable()) throw new IllegalArgumentException( "Column (id = " + columnId + ") is not groupable. Column class is " + column.getClass() + " ; specify sortingExpression or groupingExpression for <o:column> to " + "make it groupable"); } setGroupingRules(groupingRules); }