Author: vbaranov
Date: 2008-04-28 08:41:12 -0400 (Mon, 28 Apr 2008)
New Revision: 8230
Modified:
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
Log:
http://jira.jboss.com/jira/browse/RF-2778
Modified:
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
---
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2008-04-28
12:31:02 UTC (rev 8229)
+++
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2008-04-28
12:41:12 UTC (rev 8230)
@@ -38,8 +38,6 @@
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.apache.commons.collections.Predicate;
-import org.apache.commons.collections.iterators.FilterIterator;
import org.richfaces.component.Column;
import org.richfaces.component.Row;
import org.richfaces.component.UIDataTable;
@@ -97,10 +95,11 @@
ResponseWriter writer = context.getResponseWriter();
UIComponent header = table.getHeader();
boolean columnFacetPresent = isColumnFacetPresent(table, "header");
+ boolean isFilterByPresent = isHeaderFactoryColumnAttributePresent(table,
"filterBy");
Iterator<UIComponent> colums = table.columns();
- if (header != null ||columnFacetPresent) {
+ if (header != null || columnFacetPresent || isFilterByPresent) {
writer.startElement("thead", table);
writer.writeAttribute(HTML.class_ATTRIBUTE, "dr-table-thead", null);
String headerClass = (String) table.getAttributes().get(
@@ -113,12 +112,12 @@
headerClass, "th");
}
- if (columnFacetPresent) {
+ if (columnFacetPresent || isFilterByPresent) {
writer.startElement("tr", table);
encodeStyleClass(writer, null,
"dr-table-subheader rich-table-subheader", null,
headerClass);
- encodeHeaderFacets(context, writer, colums,
+ encodeHeaderFacets(context, writer, colums,
"dr-table-subheadercell rich-table-subheadercell",
headerClass, "header", "th", numberOfColumns);
@@ -144,7 +143,29 @@
}
return result;
}
+
+ /**
+ * Returns true if specified attribute (when present on the column)
+ * should generate header even if it is not specified on the table
+ * @param table - rendered UIDataTable
+ * @param attributeName - attribute name
+ * @return true if specified attribute should generate header on the table
+ */
+ public boolean isHeaderFactoryColumnAttributePresent(UIDataTable table, String
attributeName) {
+ Iterator<UIComponent> columns = table.columns();
+ boolean result = false;
+ while (columns.hasNext() && !result) {
+ UIComponent column = columns.next();
+ if (isColumnRendered(column)) {
+ if (null != column.getValueExpression(attributeName)) {
+ result = true;
+ }
+ }
+ }
+ return result;
+ }
+
/**
* @param component
* @return