Loading...
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
TUTORIAL

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

Integrating Javascript (d3.js) into Vaadin

Fred Fred
8 years ago May 05, 2014 8:09pm

Hello Community,

So I've been trying to integrate the d3.js javascript library into a Vaadin project, in fact I've read the basics here  https://vaadin.com/blog/-/blogs/vaadin-7-loves-javascript-components and tried to implement this little example: http://www.rapidpm.org/2013/10/using-javascript-libraries-d3-in-vaadin.html .

Vaadin does find the js libraries, but I keep getting an Error I'm not able to solve:
Could not initialize JavaScriptConnector because no JavaScript init function was found. Make sure one of these functions are defined:com_example_vaadind3test_Diagramcom_vaadin_ui_AbstractJavaScriptComponentcom_vaadin_ui_AbstractComponentcom_vaadin_server_AbstractClientConnector

Please see the attached screenshot for more detail on the project setup. I've done everything exactly as suggested in the little tuturial above.

Have you encountered this problem before?
What does it mean and how can I solve it?

Thanks

 

Johannes Testori
8 years ago May 06, 2014 6:23am

Hi,

Your javascript-connector should be called com_example_vaadind3test_Diagram.js and should contain the following:

window.com_example_vaadind3test_Diagram = function() {
    // whatever ...
};

 

Fred Fred
8 years ago May 06, 2014 7:54am

Thank you very much for your fast help.
I've also moved the .js filed in the main com.example.vaadind3test package and it works!

I've added a screenshot - maybe somebody will find it useful in the future.

 

Fred Fred
8 years ago May 07, 2014 2:46pm

Hello again,

so this works so far, but when I add some changes to the javascript code, save and run the program again, these changes do not take any effect. It seems like eclipse is still using the previous version of my .js file. (see attachment)

Only if I change the .js file name (and all references to that file), changes do take effect. But that's not a sustainable solution of course.
Any ideas?

Johannes Testori
8 years ago May 08, 2014 5:28am

Hi,

did you test it with another browser? might be a caching problem.

Fred Fred
8 years ago May 08, 2014 9:12am

Indeed. Disabling the cache in fireforx with the Developer Toolbox did the job, thanks.
Is there anyway to do this with the build-in eclipse browser?

Johannes Testori
8 years ago May 08, 2014 9:20am
Fred Fred
8 years ago May 08, 2014 9:39am