Hi, all. first, sorry for my bad english… Here’s my question
I’d like some advice on my implementation of a combobox ldap search. In short, whenever the user types a character, I’m looking for information in our ldap and populate the combobox accordingly. I can not get all the information at once because there are too many entries. My code works but can it be better???
@SuppressWarnings("serial")
public class SearchComboBox extends Select {
private MemberDao memberDao;
private BUnit bunit;
public SearchComboBox(BUnit bunit) {
Assert.notNull(bunit, "Business Unit cannot be null");
this.bunit = bunit;
memberDao = AccessManagerApplication.get().getMemberDao();
// -- Using MemberFilter instead
setFilteringMode(FILTERINGMODE_OFF);
}
@Override
public void changeVariables(Object source, Map<String, Object> variables) {
String filterString = (String) variables.get("filter");
if (filterString != null)
filterString = StringUtils.strip(filterString);
if (filterString != null && filterString.length() > 2) {
items.removeAllItems();
List<Member> members = memberDao.retrieveAllByName(filterString, null, bunit);
BeanItemContainer<Member> c = new BeanItemContainer<Member>(Member.class);
setContainerDataSource(c);
c.addAll(members);
Filterable f = (Filterable) c;
f.addContainerFilter(new MemberFilter(getItemCaptionPropertyId(), filterString));
} else {
// -- Be sure that the selected key is not here because it fires the change event
if (!variables.containsKey("selected")) {
items.removeAllItems();
}
}
super.changeVariables(source, variables);
}
}
Any advices would be appreciated.
Thank you!