I am using Vaadin-7 and this answer was not fix for me .
I am trying to import my js file under myproject/WebContent/js/test.js
. I used @JavaScript
in my UI class as below..
@Theme("myTheme")
@SuppressWarnings("serial")
@Title("VaadinTest")
@JavaScript("js/test.js")
public class VaadinTest extends UI {
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
}
}
But I got "NetworkError: 404 Not Found - http://localhost:8080/myproject/APP/PUBLISHED/js/test.js"
error log in my firebug console.
So , how can I import js files from my custom directories ?
PS: Please don't be force me to create APP/PUBLISHED/ directory manually ! Thanks.
You can use app://
:
@JavaScript({ "app://js/test.js" })
or use:
@JavaScript({ "vaadin://js/test.js" })
Generated url inside VAADIN folder:
http://localhost:8080/myproject/VAADIN/js/test.js
the file you refer to must be reachable by the classloader relative to the package you are using it in. according to your example, lets say your package of VaadinTest
is com.example.app
and you want to access it as js/test.js
you have to put it in the directory com/example/app/js/test.js
in a "root" for the classloader to find it (e.g. src/main/java,groovy
or where resources are loaded from in your config).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With