private static void encodeFilter(FacesContext context, DataTableRenderingContext tableContext, Column column) throws IOException {
Map<String,String> params = context.getExternalContext().getRequestParameterMap();
ResponseWriter writer = context.getResponseWriter();
DataTable table = tableContext.getTable();
String widgetVar = CoreRenderer.resolveWidgetVar(table);
String filterId = column.getClientId(context) + "_filter";
String filterFunction = widgetVar + ".filter(event)";
String filterStyleClass = column.getFilterStyleClass();
String filterEvent = table.getFilterEvent();
filterStyleClass = filterStyleClass == null
? DataTableConstants.COLUMN_FILTER_CLASS
: DataTableConstants.COLUMN_FILTER_CLASS + " " + filterStyleClass;
if (column.getValueExpression("filterOptions") == null) {
String filterValue = column.getFilterValue() != null ? column.getFilterValue() : "";
writer.startElement(HTML.INPUT_ELEM, null);
writer.writeAttribute(HTML.ID_ATTR, filterId, null);
writer.writeAttribute(HTML.NAME_ATTR, filterId, null);
writer.writeAttribute(HTML.TABINDEX_ATTR, tableContext.getTabIndex(), null);
writer.writeAttribute(HTML.CLASS_ATTR, filterStyleClass, null);
writer.writeAttribute("size", "1", null); writer.writeAttribute("value", filterValue , null);
if (filterEvent.equals("keyup") || filterEvent.equals("blur"))
writer.writeAttribute("on"+filterEvent, filterFunction , null);
if (column.getFilterStyle() != null)
writer.writeAttribute(HTML.STYLE_ELEM, column.getFilterStyle(), null);
writer.endElement(HTML.INPUT_ELEM);
}
else {
writer.startElement("select", null);
writer.writeAttribute(HTML.ID_ATTR, filterId, null);
writer.writeAttribute(HTML.NAME_ATTR, filterId, null);
writer.writeAttribute(HTML.TABINDEX_ATTR, tableContext.getTabIndex(), null);
writer.writeAttribute(HTML.CLASS_ATTR, filterStyleClass, null);
writer.writeAttribute("onchange", filterFunction, null);
SelectItem[] itemsArray = (SelectItem[]) getFilterOptions(column);
Object filterVal = column.getFilterValue();
for (SelectItem item : itemsArray) {
writer.startElement("option", null);
writer.writeAttribute("value", item.getValue(), null);
Object itemVal = item.getValue();
if ((filterVal == null && itemVal == null) || itemVal.toString().equals(filterVal)) { writer.writeAttribute("selected", "true", null);
}
writer.write(item.getLabel());
writer.endElement("option");
}
writer.endElement("select");
}
}
Well to start off this mode won't be interoperable with multi row headers or the static-header scrollable mode.