Search code examples
spring-bootvaadinvaadin8

JavaScriptComponentState in Vaadin 8


I am trying to import com.vaadin.shared.ui.JavaScriptComponentState. I used this import in vaadin 7, but when I update to vaadin 8 I can't do this anymore. I am using vaadin bom 8.0.3 in the pom. Any hints what I am doing wrong here?

import com.vaadin.shared.ui.JavaScriptComponentState;


public class Graph extends JavaScriptComponentState {
    private ArrayList<String> nodes;
    private ArrayList<String> edges;

   public ArrayList<String> getNodes() {
       return nodes;
   }

   public ArrayList<String> getEdges() {
       return edges;
   }
}

Error:

The import com.vaadin.shared.ui.JavaScriptComponentState cannot be resolved

Solution

  • Your pom.xml must have the vaadin-server dependency. The vaadin-bom is not enough.

    This goes in your pom.xml:

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <version>8.0.3</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    
    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-server</artifactId>
        </dependency>
        <!-- other dependencies ... -->
    </dependencies>