I use vaadin 7 and I create special class for calling external javascript functions
I set annotation on the class @JavaScript({“my.js”}) but where my.js file must be located? I set file in VAADIn folder also in package of the Class in themes folder in layouts folder but my function is never called. its seems like annotation is not load my.js file?
here is class
@JavaScript({"my.js"})
class ExtJavaScript extends AbstractJavaScriptComponent {
public ExtJavaScript() {
super();
}
public void callJSFunction() {
callFunction("mytestfunction");
}
}
If set @JavaScript({“http://localhost:8084/Test/VAADIN/my.js”}) and place my.js file in vadin folder then file is loadded and functions are executed.
Is it possible to set relative path inside annotaion @JavaScript({})?
Yes, you can use relative URLs in the annotation. The base URL is the URL of the PUBLISHED directory, so if you wanted to load a file from the VAADIN directory for example, you’d do something like @JavaScript(“…/…/VAADIN/my.js”).