@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
super.encodeBegin(context, component);
ComboBoxFilter filter = ((ComboBoxFilter) component);
ExpressionFilterCriterion currentCriterion = (ExpressionFilterCriterion) filter.getValue();
ResponseWriter writer = context.getResponseWriter();
writer.startElement("select", component);
String clientId = writeIdAttribute(context, component);
writeNameAttribute(context, component);
writer.writeAttribute("size", "1", null);
Rendering.writeStyleAndClassAttributes(writer, filter.getStyle(), filter.getStyleClass(), "o_fullWidth");
writer.writeAttribute("onchange", getFilterSubmissionScript(filter), null);
writer.writeAttribute("onclick", "event.cancelBubble = true;", null);
writer.writeAttribute("onkeydown", "O$.stopEvent(event);", null);
writer.writeAttribute("dir", filter.getDir(), "dir");
writer.writeAttribute("lang", filter.getLang(), "lang");
boolean thereAreEmptyItems = false;
Collection<Object> criterionNamesCollection = filter.calculateAllCriterionNames(context);
for (Iterator<Object> criterionIterator = criterionNamesCollection.iterator(); criterionIterator.hasNext();) {
Object criterionObj = criterionIterator.next();
if (isEmptyItem(criterionObj)) {
thereAreEmptyItems = true;
criterionIterator.remove();
}
}
List<Object> criterionNames = new ArrayList<Object>(criterionNamesCollection);
String allRecordsCriterionName = filter.getAllRecordsText();
String predefinedCriterionsClass = getPredefinedCriterionClass(context, filter);
writeOption(writer, component, PREDEFINED_CRITERION_PREFIX + ALL, allRecordsCriterionName,
currentCriterion == null,
predefinedCriterionsClass);
FilterCondition condition = currentCriterion != null ? currentCriterion.getCondition() : null;
if (thereAreEmptyItems) {
String emptyRecordsCriterionName = filter.getEmptyRecordsText();
writeOption(writer, component, PREDEFINED_CRITERION_PREFIX + EMPTY, emptyRecordsCriterionName,
condition != null && condition.equals(FilterCondition.EMPTY) && !currentCriterion.isInverse(),
predefinedCriterionsClass);
String nonEmptyRecordsCriterionName = filter.getNonEmptyRecordsText();
writeOption(writer, component, PREDEFINED_CRITERION_PREFIX + NON_EMPTY,
nonEmptyRecordsCriterionName,
condition != null && condition.equals(FilterCondition.EMPTY) && currentCriterion.isInverse(),
predefinedCriterionsClass);
}
Converter converter = getConverter(filter);
Object currentCriterionArg = currentCriterion != null ? currentCriterion.getArg1() : null;
String currentCriterionStr = converter.getAsString(context, filter, currentCriterionArg);
boolean textCriterionSelected = false;
for (Object criterionObj : criterionNames) {
String criterionName = converter.getAsString(context, filter, criterionObj);
boolean selected = currentCriterion instanceof ExpressionFilterCriterion &&