Integrating Javascript (d3.js) into Vaadin

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-component
s 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_Diagram
com_vaadin_ui_AbstractJavaScriptComponent
com_vaadin_ui_AbstractComponent
com_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

13576.jpg

Hi,

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

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

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.

13579.jpg

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?
13584.jpg

Hi,

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

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?

I have never used the built-in browser. isn’t it just an embedded internet explorer? maybe it helps if you disable the caching in your ie

There seems no permanent way to do that in IE. What does work is using IE with the developer view (press F12) and, under network settings, “always refresh from server” enabled.

However, this is automatically disabled again after you close IE, and this change does also not take effect in eclipse built in browser.

Therefore
firefox + developer toolbox
seems to be the way to go…