passing variables to JavaScript Annotation page

On Vaadin 8 - I have a JavaScript file that is included in the Application as an annotation @com.vaadin.annotations.JavaScript(“page.js”) on the UI.
Is it possible to pass a character string variable to the JavaScript ?

Would that be a static parameter (page.js?foo=bar) or a dynamic parameter (page.js?foo={$bar})? I think the former might work as is (although I haven’t tested it); there’s no existing mechanism for the latter. Looking at the code, I think the variable information would need to swim from the server-side UildWriter (where Dependencies like @JavaScript are gathered): https://github.com/vaadin/framework/blob/master/server/src/main/java/com/vaadin/server/communication/UidlWriter.java#L304
into the client-side DependencyLoader and ResourceLoader
https://github.com/vaadin/framework/blob/master/client/src/main/java/com/vaadin/client/DependencyLoader.java#L97
https://github.com/vaadin/framework/blob/master/client/src/main/java/com/vaadin/client/ResourceLoader.java#L185

Generally, it’s probably easier to expose a suitable function from your JavaScript code and execute it with JavaScript.eval("yourfunction('someparameter')").

Sorry about the delay in replying - it would be a static parameter (from the web.xml file). We will try either approach and see how we get on.

Thanks - we have followed your advice "to expose a suitable function from your JavaScript code and execute it with JavaScript.eval(“yourfunction(‘someparameter’)”) - that works fine,