Class ConsoleFreemarkerMixin.Builder

java.lang.Object
org.apache.juneau.rest.server.view.freemarker.FreemarkerMixin.Builder
org.apache.juneau.console.freemarker.ConsoleFreemarkerMixin.Builder
All Implemented Interfaces:
ViewMixinBuilder<FreemarkerMixin.Builder>
Enclosing class:
ConsoleFreemarkerMixin

  • Constructor Details

  • Method Details

    • basePath

      Sets the classpath base path under which template resources are resolved.

      Defaults to "/". A typical configured value is "/templates/" — the same Spring-Boot-compatible layout convention the sibling JSP / Thymeleaf / Mustache bridges use.

      Covariantly narrowed to this Builder so a fluent chain can mix inherited setters (e.g. basePath(String)) with the console-specific chromeTemplate(String) / registerToolkitPack(ToolkitPack) in any order.

      Specified by:
      basePath in interface ViewMixinBuilder<FreemarkerMixin.Builder>
      Overrides:
      basePath in class FreemarkerMixin.Builder
      Parameters:
      value - The base path. null or blank values reset to the default FreemarkerMixin.DEFAULT_BASE_PATH.
      Returns:
      This object.
    • chromeTemplate

      Sets the consumer chrome template that <@page> includes after capturing its body.

      Resolved on the consumer's own basePath-rooted loader. Defaults to ConsoleFreemarkerMixin.DEFAULT_CHROME_TEMPLATE.

      Parameters:
      chromeTemplate - The chrome template name. Must not be null.
      Returns:
      This object.
    • registerToolkitPack

      Registers an app-supplied ToolkitPack.Kind.RUNTIME toolkit pack with no dependencies.

      Same as registerToolkitPack(ToolkitPack) with kind(RUNTIME) and the default resolver.

      Parameters:
      name - The pack name.
      cssPaths - Ordered CSS asset paths.
      jsPaths - Ordered JS asset paths.
      Returns:
      This object.
    • registerToolkitPack

      Registers an app-supplied toolkit pack.

      A pack with the name of a built-in or earlier pack replaces it completely, including its dependsOn. build() validates the pack graph.

      Parameters:
      pack - The pack.
      Returns:
      This object.
    • providedPacks

      Names packs the app's chrome already loads. A provided pack contributes no URLs; its dependencies still load unless they are provided too.
      Parameters:
      names - Registered pack names.
      Returns:
      This object.
    • requirePacks

      Opts in to the startup WebJar check: the named packs (for example "charts") are expanded through dependsOn and every WebJar they reach is probed when the mixin is built, so a missing org.webjars.npm:echarts fails at startup (E-70) instead of on the first chart page. An app pack registered with registerToolkitPack(ToolkitPack) that depends on "echarts" opts in too.
      Parameters:
      names - Registered pack names.
      Returns:
      This object.
    • cardRequires

      Adds packs every card of a type requires, after the built-in one (datatables → "datatables-glue").
      Parameters:
      type - The card type.
      packs - Registered pack names.
      Returns:
      This object.
    • cardType

      Registers a server-side card type handler for this mixin's <@card> directive, on top of CardTypeRegistry.standard().

      Most custom cards need only a JS handler; register a CardTypeHandler here when the server must validate or enrich the body. To also load toolkit packs for the type, use cardRequires(String, String...).

      Parameters:
      handler - The handler. Must not be null.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - E-21 bad type name; E-22 reserved type; E-20 already registered.
    • devMode

      public ConsoleFreemarkerMixin.Builder devMode(boolean value)
      Validates every page contract against juneau-page.schema.json when <@console> closes, and fails the render with E-14 on any finding.

      Defaults to the juneau.console.devMode system property. Intended for development and tests; it parses and validates the contract on every render.

      Example:

      @Bean public FreemarkerMixin freemarker() { return ConsoleFreemarkerMixin.create().devMode(true).basePath("/templates/").build(); }

      Parameters:
      value - Whether to validate.
      Returns:
      This object.
    • adopterAssets

      Enables the assetUrl(path) template function that versions the adopter's own static assets.

      assetUrl('/js/app.js') returns /js/app.js?v=<crc32 of the bundled bytes>, where the bytes are read once (and the token cached) from resourceRoot + path on loader. This is the adopter-side counterpart of Juneau's own viewAssetUrl/consoleJsUrl/chromeCssUrl/themeAssetUrl cache-busters, for files the servlet container's static handler serves. A path with a query string, a non-root-absolute path (e.g. an external URL), or a path naming no bundled resource is returned unchanged (the last also logs a warning in dev mode). The URL path itself is never rewritten, so any context-path prefix must be added by the template.

      Example:

      @Bean public FreemarkerMixin freemarker() { return ConsoleFreemarkerMixin.create() .basePath("/templates/") .adopterAssets(getClass().getClassLoader(), "static") // /js/app.js -> classpath static/js/app.js .build(); }

      <script src="${assetUrl('/js/app.js')}"></script>

      Parameters:
      loader - The class loader that holds the assets. Must not be null.
      resourceRoot - The classpath directory the URL paths are relative to (e.g. "static"); a leading and trailing slash are optional. Must not be null.
      Returns:
      This object.
    • build

      Builds the ConsoleFreemarkerMixin.

      Overrides FreemarkerMixin.Builder#build() — without this override, the inherited method would silently return a plain FreemarkerMixin, not a ConsoleFreemarkerMixin.

      Overrides:
      build in class FreemarkerMixin.Builder
      Returns:
      A new ConsoleFreemarkerMixin instance.