Package org.apache.tapestry5.internal.services

# Interface DocumentLinker

All Known Implementing Classes:
  `DocumentLinkerImpl`, `PartialMarkupDocumentLinker`

public interface DocumentLinker
Responsible for injecting script and style links into the <head> and <body> element of the rendered HTML document.

Since:
  5.4
See Also:
  - `ModuleManager.writeInitialization(org.apache.tapestry5.dom.Element, java.util.List, java.util.List)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addCoreLibrary(String libraryURL)`
  A special case used only for the libraries that are part of the core stack, which itself contains RequireJS and is used to bootstrap up to adding non-core libraries.
  `void`
  `addInitialization(InitializationPriority priority, String moduleName, String functionName, JSONArray arguments)`
  Adds initialization, based on invoking functions exported by JavaScript modules.
  `void`
  `addLibrary(String libraryURL)`
  Adds a link to load a non-core JavaScript library.
  `void`
  `addModuleConfigurationCallback(ModuleConfigurationCallback callback)`
  Adds a module configuration callback for this request.
  `void`
  `addScript(InitializationPriority priority, String script)`
  Adds JavaScript code.
  `void`
  `addStylesheetLink(StylesheetLink stylesheet)`
  Adds a link to load a CSS stylesheet.

- ## Method Details

  - ### addLibrary

    void addLibrary(String libraryURL)
    Adds a link to load a non-core JavaScript library. These libraries are loaded, sequentially, only once the core libraries have loaded and initialized. Thus difference between core libraries and other libraries is new in 5.4, and represents a conflict between asynchronous loading of modules (introduced in 5.4) and sequential loading of libraries (in 5.3 and earlier).

  - ### addCoreLibrary

    void addCoreLibrary(String libraryURL)
    A special case used only for the libraries that are part of the core stack, which itself contains RequireJS and is used to bootstrap up to adding non-core libraries.
    Since:
      5.4

  - ### addStylesheetLink

    void addStylesheetLink(StylesheetLink stylesheet)
    Adds a link to load a CSS stylesheet.

  - ### addModuleConfigurationCallback

    void addModuleConfigurationCallback(ModuleConfigurationCallback callback)
    Adds a module configuration callback for this request.
    Parameters:
      `callback` - a `ModuleConfigurationCallback`. It cannot be null.
    Since:
      5.4

  - ### addScript

    void addScript(InitializationPriority priority, String script)
    Adds JavaScript code. The code is collected into a single block that is injected just before the close body tag of the page (in a full page render) and collected as the "script" property of the partial page render response. The JavaScript is executed after the page loads (or in an Ajax update, after external JavaScript libraries are loaded and the DOM is updated). This method may be called multiple times for the same priority and the script will be accumulated.
    Parameters:
      `priority` - when to execute the provided script
      `script` - statement to add to the block (a newline will be appended as well)

  - ### addInitialization

    void addInitialization(InitializationPriority priority, String moduleName, String functionName, JSONArray arguments)
    Adds initialization, based on invoking functions exported by JavaScript modules.
    Parameters:
      `priority` - priority at which to perform initialization
      `moduleName` - name of module; the module exports a single function, or a map of functions
      `functionName` - name of function exported by module, or null (if the module exports a single function)
      `arguments` - arguments to pass to the function, or null if no arguments
    Since:
      5.4