I use version 1.0-alpha-4 (I know it's old, but we stick to vaadin 7). Maybe this issue was addressed in later releases. Actually, the question can be set this way: can I filter this term?
For now I see that if I filter the term by length say as follows:
public class OrganizationSuggestionProvider implements AutocompleteSuggestionProvider {
@Autowired
private DadataService dadataService;
public OrganizationSuggestionProvider(DadataService dadataService) {
this.dadataService = dadataService;
}
@Override
public Collection<AutocompleteSuggestion> querySuggestions(AutocompleteQuery autocompleteQuery) {
if (Objects.nonNull(autocompleteQuery) && StringUtils.isNotBlank(autocompleteQuery.getTerm())) {
String term = autocompleteQuery.getTerm();
boolean onlyDigits = CustomStringUtils.containsOnlyDigits(term);
if (term.length() >= 5) { // the crucial line
try {
LegalEntityRequest request = new LegalEntityRequest(term, Integer.valueOf(autocompleteQuery.getLimit()).toString());
LegalEntityResponse response = dadataService.findLegalEntities(request);
return SuggestionUtils.getFilteredSuggestions(response);
} catch (ExternalIntegrationException e) {
e.printStackTrace();
return Collections.emptyList();
}
}
}
return Collections.emptyList();
}
}
then I face missing suggestions for some cases (looks like they get cached in the Provider).
For example, I see that the method is enterd with term "771", empty collection of suggestions gets returned as the tern is too short. Just a guess: the provider cached empty collection for "771" and assumes that nothing can be found if this string gets extended. If I add a character to term - "7712", the method is not entered at all. The same for "77124" - though the length of term would be OK in the comparisson with 5. And only if I prepend the term with a space like " 77124", I see the suggestions (key for the cache lookup doesn't begin with prefix "771" any more?). The provider reacts to this first space character in the term.
Most of the autocomplete libs allow to set minimal length of the input. Can you please tell how to get it working with the current add-on?
I use version 1.0-alpha-4 (I know it's old, but we stick to vaadin 7). Maybe this issue was addressed in later releases. Actually, the question can be set this way: can I filter this term? For now I see that if I filter the term by length say as follows:
public class OrganizationSuggestionProvider implements AutocompleteSuggestionProvider {
}
then I face missing suggestions for some cases (looks like they get cached in the Provider). For example, I see that the method is enterd with term "771", empty collection of suggestions gets returned as the tern is too short. Just a guess: the provider cached empty collection for "771" and assumes that nothing can be found if this string gets extended. If I add a character to term - "7712", the method is not entered at all. The same for "77124" - though the length of term would be OK in the comparisson with 5. And only if I prepend the term with a space like " 77124", I see the suggestions (key for the cache lookup doesn't begin with prefix "771" any more?). The provider reacts to this first space character in the term.
Most of the autocomplete libs allow to set minimal length of the input. Can you please tell how to get it working with the current add-on?