Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

TUTORIALVaadin lets you build secure, UX-first PWAs entirely in Java.
Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Calling javascript synchronously by Enver Haase, 2 weeks ago
SuggestField Add-on
Hi, I am using the SuggestField Add-on and I am quit satisfied with it. But now I have a little problem, probably soemone can tell me the reason: If I set a value it is not displayed in the field but it has been set. I think the reason migtht be an error in my code, I hope someone can give me an advice:
public OrganizationCustomerSuggestionField(Organization organization, OrganizationCustomerType organizationCustomerType) {
this.setLocale(UI.getCurrent().getLocale());
this.setImmediate(true);
this.setInputPrompt(Lang.getString("playerSearch", getLocale()));
this.setWidth(100, Unit.PERCENTAGE);
this.setNewItemsAllowed(false);
//
// Set the suggestion handler
//
this.setSuggestionHandler(new SuggestionHandler() {
/**
*
*/
private static final long serialVersionUID = 5936331305246105024L;
@Override
public List<Object> searchItems(String query) {
organizationCustomers = OrganizationCustomerUtils.searchForName(organization, organizationCustomerType, query);
List<Object> results = new ArrayList<>();
for(OrganizationCustomer customer : organizationCustomers)
results.add(customer);
return results;
}});
//
// Create suggestion converter
//
this.setSuggestionConverter(new SuggestionConverter() {
/**
*
*/
private static final long serialVersionUID = -8342054010047293L;
@Override
public SuggestFieldSuggestion toSuggestion(Object item) {
// TODO Auto-generated method stub
SuggestFieldSuggestion sug = new SuggestFieldSuggestion();
sug.setId(((OrganizationCustomer) item).getUser().getPid()+"");
sug.setDisplayString(((OrganizationCustomer) item).getUser().getSurname().toUpperCase()+" "+((OrganizationCustomer) item).getUser().getFirstname());
return sug;
}
@Override
public Object toItem(SuggestFieldSuggestion suggestion) {
for(OrganizationCustomer customer : organizationCustomers) {
if((customer.getUser().getPid()+"").equals(suggestion.getId()))
return customer;
}
return null;
}});
}
Thank you,
Florian
Last updated on
You cannot reply to this thread.