Can't change property in BeanItemContainer

Hi guys,

I’m using the Vaadin Calendar with a BeanItemContainer as container.
I can add my events and they aare well displaying in the Calendar but when I’m trying to drag an event, I got this error :

Caused by:$ReadOnlyException
    at com.vaadin.ui.components.calendar.ContainerEventProvider.eventMove(
    at com.vaadin.ui.Calendar.fireEventMove(
    at com.vaadin.ui.Calendar$CalendarServerRpcImpl.eventMove(
    ... 37 more

Which corresponds to the following line in the ContainerEventProvider class :


I tried to manually set this property to readOnly = true and to change manually the value, but I’m getting the same error.
I also can display the value if I’m calling the getValue() method.

I really can’t figure out what’s wrong, here’s my code :

@UIScoped // Using the cdi-MVP addon
public class CalendarComponent extends ViewComponent {

    private BeanItemContainer<CalendarEvent> container;
    private CustomCalendar calendar; //Just an extend of the calendar, I only overrided the getDayNamesShort() method

    public void init() {
        container = new BeanItemContainer<CalendarEvent>(CalendarEvent.class);
        calendar.setContainerDataSource(container, "caption", "description", "start", "end", "styleName");

// called after a fireEvent(), it works fine because it displays the events on the calendar
    public void setEventList(final List<CalendarEvent> listeEvents) {
        container.sort(new Object[]{"start"}, new boolean[]

Any ideas ?



I “solved” the problem using BeanContainer instead of BeanItemContainer, and everything is working.

This guy faced the same problem as me :

He explained why it didn’t work with the BeanItemContainer, it has something to do with hashCode() method, but I don’t understand the point.

It is hard for me to see how using BeanContainer instead of BeanItemContainer solves the issue you mentioned above, although it can solve other potential problems. I suppose you also made other changes than just changing the container type.

The ReadOnlyException was thrown because your BeanItemContainer was initialized with the interface CalendarEvent, which only contains the getters and no setters. Thus, the properties are detected as read-only, as properties are scanned from the given class rather than the actual classes of the event instances.