Calendar component: Exception in adding event

I want to use the newly added calendar component to perform the following:

  1. Like Vaadin demo, select a range of dates by dragging on the calendar that automatically pop-ups event editor and when saved, it saves to Event Entity and updates the calendar.
  2. Updates my own google or MS outlook calendar in parallel.

I’m stuck at the beginning to create an event. I have a very simple interface called Task to add events.
Here is the exception i am getting:

java.lang.UnsupportedOperationException: Use datasource for changing data items of EntityCalendarEventProvider
	at com.haulmont.cuba.gui.components.calendar.EntityCalendarEventProvider.addEvent(
	at com.haulmont.cuba.gui.components.EditorWindowDelegate.commit(
	at com.haulmont.cuba.web.gui.WebWindow$Editor.commitAndClose(
	at com.haulmont.cuba.gui.components.AbstractEditor.commitAndClose(
	at com.haulmont.cuba.gui.components.EditorWindowDelegate$2.actionPerform(
	at com.haulmont.cuba.web.gui.components.WebButton.performAction(
	at com.haulmont.cuba.web.gui.components.WebButton.lambda$new$61446b05$1(

Here is my Task entity

@Entity(name = "calendarandgoogle$Task")
public class Task extends StandardEntity {
    private static final long serialVersionUID = -4292269014751733171L;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "EMPLOYEE_ID")
    protected Employee employee;

    @Column(name = "CAPTION")
    protected String caption;

    @Column(name = "START_DATE")
    protected Date startDate;

    @Column(name = "END_DATE")
    protected Date endDate;

    @Column(name = "DESCRIPTION")
    protected String description;

    @Column(name = "STYLE_NAME")
    protected String styleName;

    @Column(name = "ALL_DAY")
    protected Boolean allDay;


Here is the Task controller

public class TaskEdit extends AbstractEditor<Task> {

    private CheckBox allDayField;
    private TextField captionField;
    private TextField descriptionField;
    private PickerField employeeField;
    private DateField endDateField;
    private DateField startDateField;
    private TextField styleNameField;

    Calendar calendar;

    public void init(Map<String, Object> params) {

        startDateField.setValue(new Date());
        endDateField.setValue(new Date());

    protected boolean postCommit(boolean committed, boolean close) {
        if (committed) {
        return super.postCommit(committed, close);
    public void addEvent() {
        SimpleCalendarEvent calendarEvent = new SimpleCalendarEvent();


Hello, Mortoza!

  1. The stack trace of your exception says that you set datasource for Calendar but try to add CalendarEvent directly. When you use datasource with Calendar, all manipulations with events must be via datasource, because events represented with entities. It’s not clear from the documentation.

  2. Currently, Calendar doesn’t have RangeSelectListener, but we have plans to add it in future releases. Now you can unwrap Calendar and add RangeSelectHandler via Vaadin API. For example:

com.vaadin.ui.Calendar vaadinCalendar = (com.vaadin.ui.Calendar) WebComponentsHelper.unwrap(calendar);
        vaadinCalendar.setHandler((CalendarComponentEvents.RangeSelectHandler) event ->
                handleRangeSelect(event.getStart(), event.getEnd()));

I’ve prepared more detailed demo project and you can get it from github.



Thank you so much Gleb.
with regards to the 2nd point, Is it possible we can update MS Outlook calendar with this event ?

Hi Gleb
The sample is awesome. I have explored the Calendar sample app and tried the work on a weekly display of the Calendar. It is displaying the weekly view, events are saved to database but not displayed in the weekly view that I can see in monthly view. Any clue why it is not displayed in weekly view using time?

I have attached the modified sample app. (328.0K)

Hello, Mortoza!

In your sample, you have missed endDateProperty and startDateProperty, so Calendar doesn’t know which entity fields use to display events.

About external calendars, sorry, but I don’t familiar with they API and I don’t have any advice. But when you commit Event entity (In your sample Task entity) you have all necessary information which you can use to add event to external calendars, just place your code in addCloseWithCommitListener of Task editor (where I just refresh the datasource) or add datasource listeners and update external calendars according to ds changes.



Thank you Gleb

:ticket: See the following issue in our bug tracker: