Class ServerPagesBundle.ViewsBuilder

java.lang.Object
ru.vyarus.guicey.gsp.ServerPagesBundle.ViewsBuilder
Enclosing class:
ServerPagesBundle

public static class ServerPagesBundle.ViewsBuilder extends Object
Global server pages support bundle builder.
  • Constructor Details

    • ViewsBuilder

      public ViewsBuilder()
  • Method Details

    • addViewRenderers

      public ServerPagesBundle.ViewsBuilder addViewRenderers(io.dropwizard.views.common.ViewRenderer... renderers)
      Additional view renderers (template engines support) to use for ViewBundle configuration. Duplicate renderers are checked by renderer key (e.g. "freemarker" or "mustache") and removed.

      NOTE: default renderers are always loaded with service loader mechanism so registered listeners could only extend the list of registered renderers (for those renderers which does not provide descriptor for service loading).

      Parameters:
      renderers - renderers to use for global dropwizard views configuration
      Returns:
      builder instance for chained calls
      See Also:
      • ViewBundle(Iterable)
    • viewsConfiguration

      public <T extends io.dropwizard.core.Configuration> ServerPagesBundle.ViewsBuilder viewsConfiguration(io.dropwizard.views.common.ViewConfigurable<T> configurable)
      Configures configuration provider for ViewBundle (usually mapping from yaml configuration).

      Note that if you need to just modify configuration in one of server pages bundles, you can do this with viewsConfigurationModifier(String, ViewRendererConfigurationModifier) - special mechanism to overcome global views limitation.

      Type Parameters:
      T - configuration object type
      Parameters:
      configurable - views configuration lookup.
      Returns:
      builder instance for chained calls
      See Also:
    • viewsConfigurationModifier

      public ServerPagesBundle.ViewsBuilder viewsConfigurationModifier(String name, ViewRendererConfigurationModifier modifier)
      Dropwizard views configuration modification. In contrast to views configuration object provider (viewsConfiguration(ViewConfigurable)), this method is not global and so modifications from all registered server page applications will be applied.

      The main use case is configuration of the exact template engine. For example, in case of freemarker this could be used to apply auto includes:

       .viewsConfigurationModifier("freemarker", config -> config
                               // expose master template
                               .put("auto_include", "/com/my/app/ui/master.ftl"))

      Note that configuration object is still global (because dropwizard views support is global) and so multiple server page applications could modify configuration. For example, if multiple applications will declare auto includes (example above) then only one include will be actually used. Use printViewsConfiguration() to see the final view configuration.

      Parameters:
      name - renderer name (e.g. freemarker, mustache, etc.)
      modifier - modification callback
      Returns:
      builder instance for chained calls
    • printViewsConfiguration

      public ServerPagesBundle.ViewsBuilder printViewsConfiguration()
      Prints configuration object used for dropwizard views bundle (ViewBundle). Note that initial views configuration object binding is configured with viewsConfiguration(ViewConfigurable) and it could be modified with viewsConfigurationModifier(String, ViewRendererConfigurationModifier). Printing of the final configuration (after all modification) could be useful for debugging.
      Returns:
      builder instance for chained calls
    • enableFreemarkerCustomClassLoadersSupport

      public ServerPagesBundle.ViewsBuilder enableFreemarkerCustomClassLoadersSupport()
      Configures custom freemarker TemplateLoader so freemarker could also see templates declared in custom class loaders.
      Returns:
      builder instance for chained calls
      See Also:
    • build

      public ServerPagesBundle build()
      Returns:
      configured bundle instance