例如:
ListSelect select = new ListSelect("Templates", templatesContainer) {
@Override
public String getItemCaption(Object itemId) {
MyTemplate t = (MyTemplate) itemId;
return t.getTitle() + "-" + t.getId();
}
};
或者,如果你使用的容器,你可以直接使用它:
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;
}
};