@Retention(value=RUNTIME) @Target(value=TYPE) @Documented @Repeatable(value=JavaScript.Container.class) public @interface JavaScript
Component
class. For adding
multiple JavaScript files for a single component, you can use this annotation
multiple times.
It is guaranteed that dependencies will be loaded only once. The files
loaded will be in the same order as the annotations were on the class.
However, loading order is only guaranteed on a class level; Annotations
from different classes may appear in different order, grouped by the
annotated class. Also, files identified by @JavaScript
will be
loaded after JsModule
and before
CssImport
.
NOTE: while this annotation is not inherited using the
@Inherited
annotation, the annotations of the possible
parent components or implemented interfaces are read when sending the
dependencies to the browser.
NOTE: Currently all frontend resources are bundled together into one big
bundle. This means, that JavaScript files loaded by one class will be
present on a view constructed by another class. For example, if there are
two classes RootRoute
annotated with @Route("")
, and
another class RouteA
annotated with @Route("route-a")
and
@JavaScript("./src/javascript.js")
, the javascript.js
will be
run on the root route as well.
public abstract String value
Component
in the browser.
Relative URLs are interpreted as relative to the configured
frontend
directory location. You can prefix the URL with
context://
to make it relative to the context path or use an
absolute URL to refer to files outside the frontend directory.
Copyright © 2019. All rights reserved.