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, 3 weeks ago
Use custom Converter for ListSelect
Is it possible to use a custom Converter for the ListSelect Component?
This is what I tried:
ListSelect ls = new ListSelect();
ls.setConverter((Converter) new MyCustomConverter());
ObjectToDisplay ots = new ObjectToDisplay();
// ls.setConvertedValue(ots ); // Converter is called but ListSelect stays empty
lsConstruction.addItem(ots ); // Did not work
However, the ListSelect stays empty.
Thanks for any help!
Last updated on
Surely, you can.
I wrote some custom fields like gridField, twinGridField. You can read the code and figure out how to.
https://github.com/jianglibo/first-vaadin
Last updated on
This solved my Problem:
I used setItemCaption() instead of a converter.
final ListSelect ls = new ListSelect ();
final BeanItemContainer<ObjectToDisplay> container = new BeanItemContainer<>(ObjectToDisplay.class, objectList); ls.setContainerDataSource(container);
for (final ObjectToDisplay o : objectList){
ls.setItemCaption(o, yourDesiredFormatFunction(o));
}
Last updated on
You cannot reply to this thread.