我做了以下解决方法,但我仍然想知道如何制作一个按钮:
// create container
IndexedContainer container = new IndexedContainer(...);
container.addContainerProperty("stacktrace", String.class, null);
// set data
importSession.getRows().forEach(importSessionRow -> {
Item item = gpcontainer.getItem(importSessionRow.getId());
item.getItemProperty("stacktrace").setValue(importSessionRow.isHasStacktrace() ? "/admin/instrument/import/row/" + importSessionRow.getId() + "/stacktrace.html" : null);
});
// set renderer
grid.getColumn("stacktrace").setRenderer(new HtmlRenderer(),
new Converter<String, String>() {
@Override
public String convertToModel(String value,
Class<? extends String> targetType, Locale locale)
throws Converter.ConversionException {
return "not implemented";
}
@Override
public String convertToPresentation(String value,
Class<? extends String> targetType, Locale locale)
throws Converter.ConversionException {
return value != null ? "<a href='" + value + "' target='_blank'>view</a>" : null;
}
@Override
public Class<String> getModelType() {
return String.class;
}
@Override
public Class<String> getPresentationType() {
return String.class;
}
});