Issue #391 resolved

Auto Complete TextField With converter gives incorrect suggestions (With how to fix code)

Oded Etzion
created an issue

The following code:

SuggestionProvider<MyEntity> suggestionProvider = SuggestionProvider.create(stringConverter, entityList); TextFields.bindAutoCompletion(textField, suggestionProvider, MyEntity.getStringConverter());

Uses the MyEntity.toString() instead of the converter.toString(MyEntity) for matching.

I found the problem in the code

Class: SuggestionProvider$SuggestionProviderString

protected boolean isMatch(T suggestion, ISuggestionRequest request) { String userTextLower = request.getUserText().toLowerCase(); String suggestionStr = suggestion.toString().toLowerCase(); return suggestionStr.contains(userTextLower) && !suggestionStr.equals(userTextLower); }

replace the bold line with: String suggestionStr = stringConverter.call(suggestion).toLowerCase();

Thanks

Comments (7)

  1. Oded Etzion reporter

    I also didn't understand why the stringConverter should be passed as callback class, I tried to pass the StringConverter itself and it worked perfectly well.

  2. Samir Hadzic
    • changed status to open

    I do agree with you for the solution. Are you able to make a pull request with the corresponding changes in order to fix the issue?

    However you said that you gave a StringConverter and it was working, how did you managed that? The SuggestionProvider is not public so I don't understand..

    PS : Don't forget to use the "code" tag available in order to format your code in a proper way.

  3. Ahmed H.

    when I provide my custom StringConverter of my Combobox with combobox.getConverter() (which I have implemented before) I get a single suggestion row with an array of Object references...is that a bug?

    when I use anonymous classes (implemented the same way as before) it works though...

  4. Log in to comment