Class FreemarkerMixin.Builder

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

Builder for FreemarkerMixin.

Mirrors FreemarkerDispatcher.Builder's configuration methods on its own surface and forwards each call into a held FreemarkerDispatcher.Builder (worker-bean composition). Implements ViewMixinBuilder so basePath(String) and cacheTemplates(boolean) are guaranteed to transfer to the sibling JSP / Thymeleaf / Mustache bridge builders.

  • 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.

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

      Sets the suffix to append to template names that don't already end with it (idempotent).

      Defaults to "" (no implicit suffix — literal template names). Typical configured values are ".ftlh" (HTML auto-escape) or ".ftl" (no auto-escape).

      Parameters:
      value - The new suffix. null resets to FreemarkerMixin.DEFAULT_TEMPLATE_SUFFIX.
      Returns:
      This object.
    • cacheTemplates

      public FreemarkerMixin.Builder cacheTemplates(boolean value)
      Sets the template-cache flag for the bridge-default configuration.

      Defaults to true (cache forever — production-safe). Set false to enable dev hot-reload (FreeMarker re-checks the underlying resource on every render).

      This flag only affects the bridge-default Configuration; user-supplied @Bean Configurations are not modified.

      Specified by:
      cacheTemplates in interface ViewMixinBuilder<FreemarkerMixin.Builder>
      Parameters:
      value - The cache flag.
      Returns:
      This object.
    • exposeFields

      public FreemarkerMixin.Builder exposeFields(boolean value)
      Sets whether the bridge-default ObjectWrapper exposes public fields (not just JavaBean getters) to templates.

      Defaults to true so simple view-model DTOs written with public fields and no getters render their field values instead of silently resolving to null/missing (see the class-level "Public-field DTOs" section). Has no effect once objectWrapper(ObjectWrapper) has been called with a non-null value — the explicit wrapper always wins.

      Parameters:
      value - The field-exposure flag.
      Returns:
      This object.
    • objectWrapper

      public FreemarkerMixin.Builder objectWrapper(freemarker.template.ObjectWrapper value)
      Sets a fully custom ObjectWrapper for the bridge-default configuration, overriding exposeFields(boolean) entirely.

      Escape hatch for consumers who need full control (e.g. a BeansWrapper with custom method/property exposure, or a third-party wrapper) without hand-rolling and registering a whole replacement Configuration bean.

      Parameters:
      value - The object wrapper. null reverts to the bridge-built DefaultObjectWrapper (per exposeFields(boolean)).
      Returns:
      This object.
    • getBasePath

      public String getBasePath()
      Reads the current base path setting (test/inspection helper).
      Returns:
      The base path. Never null.
    • getTemplateSuffix

      Reads the current template-suffix setting (test/inspection helper).
      Returns:
      The template suffix. Never null.
    • isCacheTemplates

      public boolean isCacheTemplates()
      Reads the current cache-templates setting (test/inspection helper).
      Returns:
      The cache flag.
    • isExposeFields

      public boolean isExposeFields()
      Reads the current field-exposure setting (test/inspection helper).
      Returns:
      The field-exposure flag.
    • getObjectWrapper

      public freemarker.template.ObjectWrapper getObjectWrapper()
      Reads the current object-wrapper override (test/inspection helper).
      Returns:
      The object wrapper override, or null if none has been set.
    • build

      Builds the FreemarkerMixin.
      Returns:
      A new FreemarkerMixin instance.