ThemeResource in a Grid with HtmlRenderer

I would like to use a ThemeResource in a Grid with the HtmlRenderer. Is this possible? Something like

grid.addColumn(object -> { return "<div>" + resource.toHtml() + "</div>; }, new HtmlRenderer()); Thanks in advance.


Sorry for the late reply.

The actual URL of a theme resource is normally resolved on the client side, so on the server there is no method to get a complete URL for a theme resource. However, in a basic deployment, the path is something like contextPath + “/VAADIN/themes/” + myUi.getTheme() + “/” + resource.getResourceId() . If you know the server base URL and the context path, you could create your own helper to construct such paths.

Alternatively, if you don’t need any other HTML around the ThemeResource, you could use an ImageRenderer which directly supports resources.

Not nice but a valid workaround.

Thanks for the effort.