javamavenvaadinvaadin8vaadin-charts

Has something replaced BeanItemContainer in Vaadin 8?


I downloaded a copy of the vaadin-charts-video example project from GitHub (https://github.com/vaadin-miki/vaadin-charts-video) to get a feel for how Vaadin charts are supposed to be implemented. However that project, and most of the available demo code/projects I have found seem to be written using Vaadin 7 and prior coding conventions. I am jumping in with Vaadin 8.0.5 (and JDK8)...

These errors are appearing when running Maven:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project intro-video: Compilation failure: Compilation failure:
[ERROR] /C:/Users/dev/vaadin/vaadin-charts-video/intro-video/src/main/java/org/vaadin/miki/charts/intro/IntroChartsUI.java:[19,28] cannot find symbol
[ERROR] symbol:   class BeanItemContainer
[ERROR] location: package com.vaadin.data.util
[ERROR] /C:/Users/dev/vaadin/vaadin-charts-video/intro-video/src/main/java/org/vaadin/miki/charts/intro/IntroChartsUI.java:[54,17] cannot find symbol
[ERROR] symbol:   class BeanItemContainer
[ERROR] location: class org.vaadin.miki.charts.intro.IntroChartsUI
[ERROR] /C:/Users/dev/vaadin/vaadin-charts-video/intro-video/src/main/java/org/vaadin/miki/charts/intro/IntroChartsUI.java:[54,62] cannot find symbol
[ERROR] symbol:   class BeanItemContainer
[ERROR] location: class org.vaadin.miki.charts.intro.IntroChartsUI

Can anyone tell me, has BeanItemContainer been replaced? And if so, by what?

For example, see Line 54 of https://github.com/vaadin-miki/vaadin-charts-video/blob/master/intro-video/src/main/java/org/vaadin/miki/charts/intro/IntroChartsUI.java BeanItemContainer<BookPrice> container = new BeanItemContainer<>(BookPrice.class, prices);

And if that doesn't appear to be the issue to more experienced eyes, please let me know what is...


Solution

  • Container is dead

    Vaadin 8 no longer has Container. The Vaadin data model has been largely simplified. Basically, there is no data model anymore. There are just data providers for the various elements. What you want to look into is DataProvider, as it largely replaces Container.

    A short introduction to the changes is here: https://vaadin.com/blog/-/blogs/vaadin-framework-8-comes-with-java-8-native-apis

    Generally, for most uses you will either use setItems directly or use a ListDataProvider.

    Long live Container

    To ease migrating your existing Vaadin 7 app to Vaadin 8, you can use the Vaadin 7 compatibility layer. This includes the old Vaadin data model and Container. Move to Vaadin 8 while making very few changes to your existing code base.

    See: