Certain Vaadin addons, such as Invient Charts (https://vaadin.com/directory#addon/invient-charts), require the inclusion of javascript libraries to operate.
How can this be done without having to create a custom Servlet for Vaadin applications?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using the Scaladin addon and the Scala language, this is accomplished by the following code in the init() method on your application:
Note that the javascript files being opened as InputStreams must be in the classpath. To do this using SBT, make a resources directory under the src/main dir, and put the /js dir and the .js files within. These will be put into the WEB-INF/classes dir when the war file is built. They will also appear in the classpath when you use container:start from the xsbt web plugin, so the same code allows for testing prior to making the .war file.
This approach should be able to work without Scala (but with a lot more Java code), but what fun would that be?
A more efficient way would be to load the JavaScript code into a string held in an object to avoid having to repeatedly read it in:
and then in the Vaadin Application: