use of org.zkoss.zul.Comboitem in project adempiere by adempiere.
the class AutoComplete method refresh.
/**
* Refresh comboitem based on the specified value.
*/
private void refresh(String val) {
if (comboItems == null || val == null) {
super.getChildren().clear();
return;
}
String compare = val.toLowerCase().trim();
Iterator<?> it = getItems().iterator();
for (int i = 0; i < comboItems.length; i++) {
boolean match = false;
if (compare.length() < 3) {
match = comboItems[i].toLowerCase().startsWith(compare);
} else {
match = comboItems[i].toLowerCase().contains(compare);
}
if (match) {
Comboitem comboitem = null;
if (it != null && it.hasNext()) {
comboitem = ((Comboitem) it.next());
} else {
it = null;
comboitem = new Comboitem();
super.appendChild(comboitem);
}
comboitem.setLabel(comboItems[i]);
comboitem.setDescription(strDescription[i]);
}
}
while (it != null && it.hasNext()) {
it.next();
it.remove();
}
}
Aggregations