Author: pgolawski
Date: 2008-10-31 04:28:28 -0400 (Fri, 31 Oct 2008)
New Revision: 10988
Modified:
trunk/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedTableRenderer.java
Log:
enable external filtering by printing "filter" facet into filterRow
Modified:
trunk/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedTableRenderer.java
===================================================================
---
trunk/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedTableRenderer.java 2008-10-30
16:42:08 UTC (rev 10987)
+++
trunk/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedTableRenderer.java 2008-10-31
08:28:28 UTC (rev 10988)
@@ -138,14 +138,14 @@
Iterator<UIColumn> colums = table.getSortedColumns();
// int numberOfColumns = getColumnsCount(table);
int numberOfColumns = table.getVisibleColumnsCount() + 1;
+ String headerClass = (String)
table.getAttributes().get("headerClass");
if (header != null || columnFacetPresent) {
writer.startElement("thead", table);
writer.writeAttribute(HTML.id_ATTRIBUTE, table
.getBaseClientId(context)
+ ":header", null);
writer.writeAttribute(HTML.class_ATTRIBUTE, "extdt-thead", null);
- String headerClass = (String) table.getAttributes().get(
- "headerClass");
+
// String menuId = (String) table.getAttributes().get(MENU_ID);
writer.startElement("tr", header);
@@ -201,8 +201,22 @@
headerClass, "header", HTML.th_ELEM);
}
+ else if (isColumnFacetPresent(table, "filter")){
+ encodeFilterRow(context, writer, table, table
+ .getSortedColumns(),
+ "extdt-subheadercell rich-extdt-subheadercell",
+ headerClass, "filter", HTML.th_ELEM);
+ }
writer.endElement("thead");
}
+ else if (isColumnFacetPresent(table, "filter")){
+ writer.startElement("thead", table);
+ encodeFilterRow(context, writer, table, table
+ .getSortedColumns(),
+ "extdt-subheadercell rich-extdt-subheadercell",
+ headerClass, "filter", HTML.th_ELEM);
+ writer.endElement("thead");
+ }
}
private void encodeFilterRow(FacesContext context, ResponseWriter writer,
@@ -235,7 +249,7 @@
* @return true if filtering is enabled, false otherwise
* @author pbuda
*/
- private boolean filterEnabledColumn(UIColumn dataColumn) {
+ private boolean internalFilterEnabledColumn(UIColumn dataColumn) {
return dataColumn.getFilterMethod() == null
&& dataColumn.getValueExpression("filterExpression") ==
null
&& dataColumn.getValueExpression("filterBy") != null;
@@ -255,10 +269,12 @@
UIColumn col = columns.next();
if (col instanceof UIColumn) {
UIColumn dataColumn = (UIColumn) col;
- if (filterEnabledColumn(dataColumn) && dataColumn.isRendered())
{
- enabled = true;
- break;
- }
+ if ((internalFilterEnabledColumn(dataColumn) ||
(dataColumn.getFacet("filter") != null)) &&
+ dataColumn.isRendered()
+ ) {
+ enabled = true;
+ break;
+ }
}
}
return enabled;
@@ -304,7 +320,7 @@
encodeStyleClass(writer, null, skinCellClass, headerClass,
columnHeaderClass);
UIColumn dataColumn = (UIColumn) column;
- if (filterEnabledColumn(dataColumn)) {
+ if (internalFilterEnabledColumn(dataColumn)) {
writer.startElement(HTML.DIV_ELEM, column);
addInplaceInput(context, column, buildAjaxFunction(
context, column, false,
@@ -312,6 +328,11 @@
(UIDataTable) column.getParent())));
writer.endElement(HTML.DIV_ELEM);
}
+ else if (dataColumn.getFacet("filter") != null) {
+ writer.startElement(HTML.DIV_ELEM, column);
+ dataColumn.getFacet("filter").encodeAll(context);
+ writer.endElement(HTML.DIV_ELEM);
+ }
writer.endElement(element);
}
}