Class ClientResourceLoader
java.lang.Object
com.vaadin.observability.micrometer.ClientResourceLoader
Loads a bundled client-side JavaScript resource into a
UI exactly
once. The classpath resource is read, stripped of comments and executed via
Page.executeJs(java.lang.String, java.lang.Object...). A per-UI flag keyed by
initKey guards against repeated injection.-
Method Details
-
loadOnce
public static void loadOnce(com.vaadin.flow.component.UI ui, String initKey, String resource, Class<?> owner) Injectsresourceintouionce. Subsequent calls with the sameinitKeyfor the same UI are no-ops. Missing resources or read failures are logged againstownerand otherwise ignored.- Parameters:
ui- the target UI;nullis ignoredinitKey- the per-UI data key used to ensure single injectionresource- the classpath resource path of the JavaScript to loadowner- the class whose class loader and logger are used
-
loadOnce
public static void loadOnce(com.vaadin.flow.component.UI ui, String initKey, String resource, Class<?> owner, String prelude) Injectsresourceintouionce, preceded bypreludein the same script.- Parameters:
ui- the target UI;nullis ignoredinitKey- the per-UI data key used to ensure single injectionresource- the classpath resource path of the JavaScript to loadowner- the class whose class loader and logger are usedprelude- JavaScript run immediately before the resource, ornullfor none. The way to hand the script a server-side decision it cannot read for itself; it is executed as written, so it must be server-authored and must carry no comments, which are stripped from the resource but not from this
-