Hello again,
I seem to have confused you. Currently I don't have a specific problem since I have solved it by overriding updateHints. I mentioned it on this
forum so that if others have an issue they can use my workaround.
Furthermore why would I want to override compare? It has nothing to do with the issue that I have mentioned.
My problem began with the fact that the method acceptHint(Object o) was the only way to plug into the user selection. I noticed that if I passed
list List<CustomBean> to setCompletionList, the class of the Object in acceptHint was of String.class instead of CustomBean.class. Bellow I am
posting the original updateHints to point out the problems.
- Code: Select all
public boolean updateHints(Object context) {
if (context == null) {
return false;
}
String s = context.toString();
int substringLen = s.length();
List<String> possibleStrings = new ArrayList<String>(); //<-- Here is the firs issue, the possible strings should be Object not String
for (Object o : getCompletionList()) {
String listEntry = (String) o; //<-- Here is the second problem, instead of using toString() you assume that the completion list has String.class objects
if (substringLen > listEntry.length())
continue;
if (!isCaseSensitive()) {
if (s.equalsIgnoreCase(listEntry.substring(0, substringLen)))
possibleStrings.add(listEntry); //<-- Here you add a String.class to the internal model, not the actual object, so acceptHint(Object o) will receive a String
}
else if (listEntry.startsWith(s))
possibleStrings.add(listEntry); //<-- Here you add a String.class to the internal model, not the actual object, so acceptHint(Object o) will receive a String
}
Object[] objects = possibleStrings.toArray(); //<-- Given the code above there is not reason why this shouldn't be a String[] array
setListData(objects);
return objects.length > 0;
}
I hope I have made the issue clearer.
In my workaround I am also assuming that the bean has a toString() method, what would be correct, is to force a specific interface or something.
Best Regards,
Fotis