Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix 'com.vaadin.DefaultWidgetSet' does not contain implementation for com.vaadin.addon.charts.Chart

By using "Spring Stater Project" in Eclipse/STS, I was able to have a Vaadin project up and running quickly. I want to add charting via Vaadin-Addon to the project. I have Googled trying to find how to properly add and use Vaadin Chart addon to the project. But I am confused because there so many "Guides/Tutorial", but a lot are not for spring boot or they are outdated or partial.

So I am looking for a complete Guide/Tutorial for Vaadin-SpringBoot-VaadinChart-AddOn.

This is what I have so far:

---- Pom file ----

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.aci</groupId>
    <artifactId>oversight2</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>oversight2</name>
    <description>Oversite</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.5.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
<!--        <dependency> -->
<!--            <groupId>com.vaadin</groupId> -->
<!--            <artifactId>vaadin-spring-boot</artifactId> -->
<!--            <version>1.0.0</version> -->
<!--        </dependency> -->

        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-spring-boot-starter</artifactId>
            <version>1.0.0.beta3</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.vaadin.addon</groupId>
            <version>2.0.0</version>
            <artifactId>vaadin-charts</artifactId>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <version>7.4.5</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <repositories>
        <repository>
            <id>vaadin-addons</id>
            <url>http://maven.vaadin.com/vaadin-addons</url>
        </repository>
    </repositories>

</project>

---- Java code ----

public class BasicBarChart extends AbstractVaadinChartExample {

    @Override
    public String getDescription() {
        return "Basic bar";
    }

    @Override
    protected Component getChart() {
        Chart chart = new Chart(ChartType.BAR);

        Configuration conf = chart.getConfiguration();

        conf.setTitle("Historic World Population by Region");
        conf.setSubTitle("Source: Wikipedia.org");

        XAxis x = new XAxis();
        x.setCategories("Africa", "America", "Asia", "Europe", "Oceania");
        x.setTitle((String) null);
        conf.addxAxis(x);

        YAxis y = new YAxis();
        y.setMin(0);
        Title title = new Title("Population (millions)");
        title.setVerticalAlign(VerticalAlign.HIGH);
        y.setTitle(title);
        conf.addyAxis(y);

        Tooltip tooltip = new Tooltip();
        tooltip.setFormatter("this.series.name +': '+ this.y +' millions'");
        conf.setTooltip(tooltip);

        PlotOptionsBar plot = new PlotOptionsBar();
        plot.setDataLabels(new Labels(true));
        conf.setPlotOptions(plot);

        Legend legend = new Legend();
        legend.setLayout(LayoutDirection.VERTICAL);
        legend.setHorizontalAlign(HorizontalAlign.RIGHT);
        legend.setVerticalAlign(VerticalAlign.TOP);
        legend.setX(-100);
        legend.setY(100);
        legend.setFloating(true);
        legend.setBorderWidth(1);
        legend.setBackgroundColor("#FFFFFF");
        legend.setShadow(true);
        conf.setLegend(legend);

        conf.disableCredits();

        List series = new ArrayList();
        series.add(new ListSeries("Year 1800", 107, 31, 635, 203, 2));
        series.add(new ListSeries("Year 1900", 133, 156, 947, 408, 6));
        series.add(new ListSeries("Year 2008", 973, 914, 4054, 732, 34));
        conf.setSeries(series);

        chart.drawChart(conf);

        return chart;
    }
}

@SpringUI
@VaadinServletConfiguration(productionMode = false, ui = MyVaadinUI.class)
public class MyVaadinUI extends UI {
    @Override
    protected void init(VaadinRequest vaadinRequest) {
        setContent(new BasicBarChart());
    }
}

I have create a 30 day AGPL license key

There are some sites that say I need a gwt.xml file, or can this be done with annotations

Some sites say I need to "re-compile your widgetset" which implies I need to have some plugin addition to my pom file.

Other sites say I need a web.xml but with spring-boot-vaadin Vaadin app with just run.

When I run the code, I am getting :

Widgetset 'com.vaadin.DefaultWidgetSet' does not contain implementation for com.vaadin.addon.charts.Chart. Check its component connector's @Connect mapping, widgetsets GWT module description file and re-compile your widgetset. In case you have downloaded a vaadin add-on package, you might want to refer to add-on instructions.

like image 221
KRico Avatar asked Nov 21 '15 04:11

KRico


1 Answers

The process is the same as with all add-ons. For simple apps you only need core widgets and can use the "DefaultWidgetSet". You'll need to have "ApplicationWidgetset" with your project that combines basic client side component implementations from the core with all the add-ons that you use in your project.

These are instructions from example using TouchKit add-on, but the process is basically the same:

  • Simple option using cdn.virit.in:
    • Add plugin to pom.xml
    • Add generated servlet filter to your configuration https://github.com/mstahv/vaadin-spring-touchkit/blob/master/src/main/java/org/vaadin/tkspring/Application.java#L20-L25
  • Standard solution:
    • Add vaadin-maven-plugn to pom.xml
    • Add @Widgetset annotation to your UI class
like image 187
mstahv Avatar answered Sep 22 '22 19:09

mstahv