Cannot use JavaScriptComponent

I am essaying the JavaScriptComponent and though I feel I am strictly following the indications explained in,

> Generic JavaScriptComponent

I am not being able to get it to work.

I am placing the js file in the resources folder under VAADIN, but the file/function seem not to load in the browser although all files are correctly placed in the build output and jars.

Have tried executing gradle task “processResources”, “clean” and “build”, and other gradle task combinations with no luck.

Please find attached a test project and a couple of screenshots showing my issue.

Thanks and any help is greatly appreciated.

Regards,
Carlos.

You can see in the sources tab that the js file containing the connector is not loaded in the page.

screenshot2

In the built libs (Project/build/libs) the file is correctly placed in the resources/VAADIN folder, so I don’t think I am missing anything from the building perspective.

Here you have the project:

JavaScriptComponentTest.zip (92.8 KB)

Hi,

You have to add your js file as a dependency. In the doc example time-picker-connector.js is a custom js file that contains initFunction:

...
<dependency path="vaadin://timepicker/time-picker-connector.js"/>
...

So, in your case, the jsComponent definition should be:

<jsComponent id="jsc"
                initFunctionName="testjscomp">
    <dependency path="vaadin://testjsc.js"/>
</jsComponent>

Regards,
Gleb

I was missing exactly that. Thanks for pointing me out.

Regards,
Carlos.