Using BeanItem with ObjectProperty in a Grid


I am using a Grid for displaying beans in a BeanItemContainer. Works just fine, but when beans have an ObjectProperty attribute the Grid will fails with exceptions similar to the following:

java.lang.IllegalArgumentException: Cannot remove converter, as renderer’s presentation type java.util.Date and column’s model type aren’t directly compatible with each other (in Column[propertyId:requestedAt]
at com.vaadin.ui.Grid$Column.setConverter(
at com.vaadin.ui.Grid$Column.setRenderer(
at com.vaadin.ui.Grid$Column.internalSetRenderer(
at com.vaadin.ui.Grid$Column.setRenderer(

[cut for brevity]

ObjectProperty concept
is also being used with that bean so I was wondering if I am doing something wrong here. Isn’t it possible to convert automatically via ObjectProperty#getValue() in a Grid? What am I doing wrong here?



Can you provide some code? Anyway, using ObjectProperty inside a Java-Bean sounds pretty wrong to me…


code example is rather straightforward:

import java.util.Arrays;
import java.util.Date;

import javax.servlet.annotation.WebServlet;

import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Grid;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

public class GridBeanWithObjectPropertyExample extends UI {
    protected void init(VaadinRequest request) {
        Grid grid = new Grid(new BeanItemContainer<Bean>(Bean.class, Arrays.asList(new Bean())));

        VerticalLayout layout = new VerticalLayout();
        layout.setExpandRatio(grid, 1);

    private static class Bean {
        private ObjectProperty<Date> from;

        public Bean() {
            this.from = new ObjectProperty<>(new Date(), Date.class);

        public ObjectProperty<Date> getFrom() {
            return from;

        public void setFrom(ObjectProperty<Date> from) {
            this.from = from;

    @WebServlet(value = "/*", asyncSupported = true)
    @VaadinServletConfiguration(productionMode = false, ui = GridBeanWithObjectPropertyExample.class, widgetset = "org.vaadin.gridutil.demo.DemoWidgetSet")
    public static class Servlet extends VaadinServlet {


However, the thing is, that I have to deal with some legacy bean code which have been used in a table. Those beans are used at different places. I have hoped that I can use these beans in a grid, while other forms and other tables (which shall not be replaced by a grid) are not affected.

You said that using ObjectProperties in a bean sounds pretty wrong to you … So what’s the way to go? Creating simple POJO beans and wrapping them into ObjectProperty (let’s say an OPJO :wink: beans when the data should be bound to UI components?

That looks really wrong to me as well, I don’t see the reason to wrap the bean’s fields in an ObjectProperty. …unless you are using it for some workaround in some very unusual situation, but I can’t imagine what such situation could be.

Bean is a private class, so BeanItemContainer can’t access it.

If you change the class to public (and add the grid to the layout before calling setExpandRatio) your code works. But still, there is no need to wrap from date inside an ObjectProperty.

In this case, the right way is to create simple POJOs and let BeanItemContainer wrap the collection of beans.

I suggest you should read the capters about containers/items/properties and binding data to ui components in the book of Vaadin!
It is well explained there and i could not tell you anything else.

If you still have some understanding issues after reading, i’ll gladly help you again then!