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.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Custom Renderer for Grid in Vaadin 8
Hello,
I'm trying to implement a custom Column Renderer for the Grid in Vaadin 8. Unfortunately the documentation is not reflecting recent changes in Vaadin 8, so the examples don't compile (https://vaadin.com/docs/-/part/framework/clientsidewidgets/clientsidewidgets-grid.html#clientsidewidgets.grid.renderers).
Here is what I got right now:
Server Renderer:
public class CountryRenderer extends AbstractRenderer<Grid<?>, Country> {
private static final long serialVersionUID = 1L;
public CountryRenderer() {
super(Country.class);
}
}
Client Renderer:
public class CountryRenderer implements Renderer<Country> {
@Override
public void render(RendererCellReference cell, Country country) {
// Do nothing for test purposes
}
}
Connector:
@Connect(de.xxx.renderer.CountryRenderer.class)
public class CountryRendererConnector extends AbstractGridRendererConnector<Country> {
private static final long serialVersionUID = 1L;
@Override
public de.xxx.renderer.client.CountryRenderer getRenderer() {
return (de.xxx.renderer.client.CountryRenderer) super.getRenderer();
}
}
When I try to attach the renderer I get an empty Grid (no rows). After clicking around a bit Vaadin becomes unresponsive and crashes. As of yet I was not able to catch the error with Breakpoints.
Has anyone a suggestion how to implement a custom renderer in Vaadin 8 or any working example? I would much appreciate any hint regarding this topic.
Hi,
Renderer concept was not really changed when going from Vaadin 7 to Vaadin 8, the basics are still the same. I'll need to take a look at that documentation and fix what might be incorrect, but the code you have there is pretty much what it's supposed to be. One thing I'm worried about is your Country class, does it translate to JSON and be available in both client and the server?
To see what is going on in the client-side, you should use ?debug at the end of the URL to make sure you see any errors that happen. Please make sure there are no exceptions being thrown.
Since Vaadin 8.1 you can use Vaadin Components in your Grid. See Grid.addComponentColumn. Using components makes it a bit easier to achieve your own features in a column.
//Teemu