Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Reading csv with JS/D3.js does not work right

Norma J
7 years ago Aug 26, 2015 8:11am
Kim Leppänen
7 years ago Aug 27, 2015 5:21am

Where is the data.csv file located? If it is, for example, in source code package along with your UI code, then it will not be available via a URL. You give as a parameter "data.csv", the URL being requested is probably something like http://myhost.com/myApplicationContext/data.csv. By default, everything except /VAADIN/ in the myApplicationContext is being served by the VaadinServlet and the only thing it will give you, is a UI instance. Hence, you see the HTML content of MyUI.

The real question is, how do you serve the CSV file to the browser. There are a few approaches to this. If your data.csv is dynamically created, then I'd recommend that you add the content of the CSV in the state of the component and passing it directly to your JavaScript code. If the content is static, then you can either configure your application to contain a second servlet which provides the CSV file through a default servlet instead of the VaadinServlet. A third option is to place the CSV in the VAADIN folder (along with your theme, for example) since those files are served as-is. See Book of Vaadin for more information about application resources. See this wiki article for instruction on integrating JavaScript components and how to use the state to pass the CSV content.

Norma J
7 years ago Aug 27, 2015 9:10am