Class VaadinUtils

java.lang.Object
com.vaadin.swingbridge.surrogates.util.VaadinUtils

public final class VaadinUtils extends Object
Broad, generic Vaadin UI/DOM utilities used across the surrogate layer; shared with :emulators in the SD_shelper_statics-allowed direction where needed.
  • Method Details

    • injectStyleOnce

      public static void injectStyleOnce(com.vaadin.flow.component.UI ui, String sentinelKey, String dataEmulValue, String css)
      Inject a server-managed <style> element into the given UI's element tree exactly once, guarded by a per-UI sentinel. Generic mechanism behind pseudo-element CSS that inline Style can't reach (e.g. BorderCss's TitledBorder ::before rule, SJProgressBar's progress-string ::after rule).

      The <style> lives in the UI element tree rather than going through Page.executeJs(String, Object...) / addStyleSheet: only a tree-attached Element survives a @PreserveOnRefresh reload, because Vaadin re-renders the preserved tree (it doesn't replay executeJs or re-emit already-sent dependencies). The sentinelKey guards against double-attach on a single UI and survives reload for the same reason.

      Parameters:
      ui - the target UI; no-op when null
      sentinelKey - per-UI ComponentUtil data key marking "already injected"
      dataEmulValue - value for the data-emul attribute on the <style> (identifies the rule in DevTools)
      css - the stylesheet text