Reputation: 535
I use a Vaadin ListSelect to show the options.I have a title of my template as display name but I want to add one more property (id) from templateContainer to display. How can I do it?
ListSelect select = new ListSelect("Templates", templatesContainer);
select.setItemCaptionPropertyId("title");
Upvotes: 0
Views: 435
Reputation: 2510
For example:
ListSelect select = new ListSelect("Templates", templatesContainer) {
@Override
public String getItemCaption(Object itemId) {
MyTemplate t = (MyTemplate) itemId;
return t.getTitle() + "-" + t.getId();
}
};
Or if you use container you can use it directly:
ListSelect select = new ListSelect("Templates", templatesContainer) {
@Override
public String getItemCaption(Object itemId) {
Container c = getContainerDataSource();
String title = (String) c.getContainerProperty(itemId, "title").getValue();
Integer id = (Integer) c.getContainerProperty(itemId, "id").getValue();
return title + "-" + id;
}
};
Upvotes: 3