I understand that Vaadin 8.1.0 will include a new LocalDateRenderer to work with Java 8's new date LocalDate
but in the meantime I'm trying to setup my own custom LocalDateRenderer. I've got it mostly working in that it's all hooked up but based on the documentation I need to setup an AbstractRendererConnector
but there's no such class...
The following code is all in my main UI class (for testing purposes):
private void setupGrid(Grid<Dog> grid)
{
grid.addColumn(dog -> dog.getBirthday(), new LocalDateRenderer()).setCaption("Birthday");
}
class LocalDateRenderer extends AbstractRenderer<Object, LocalDate>
{
public LocalDateRenderer()
{
super(LocalDate.class, "");
}
@Override
public JsonValue encode(LocalDate localDate)
{
return encode(DateTimeFormatter.ofPattern("MMM dd, YYYY").format(localDate), String.class);
}
}
I have confirmed that the LocalDateRenderer
is called by adding logging statements, however on the grid no values are displayed. If I use the same code but instead of LocalDate
I do it for a Long
but instead of extends AbstractRenderer
I extend NumberRenderer
with my own code then it works.
This lead me to the documentation where I need to setup the Renderer
with a AbstractRendererConnector
but whenever I try to do this I get the compiler error saying that AbstractRendererConnector
cannot be resolved to a type. And then of course I have a number of compiler errors (in the code below). My code for this (still in the main UI class) is:
@Connect(LocalDateRenderer.class)
class LocalDateRendererConnector extends AbstractRendererConnector<LocalDate>
{
@Override
public LocalDateRenderer getRenderer()
{
return (LocalDateRenderer) super.getRenderer();
}
}
Any assistance with how to get it linked up so that it displays my actual dates would be greatly appreciated. Thank you.
Also in the documentation it's not clear which class is which when they refer to TextRenderer
since they use the same name to to be different things...