Class ServerPagesBundle.ViewsBuilder

  • Enclosing class:
    ServerPagesBundle

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

      • ViewsBuilder

        public ViewsBuilder()
    • Method Detail

      • addViewRenderers

        public ServerPagesBundle.ViewsBuilder addViewRenderers​(io.dropwizard.views.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)
      • viewsConfigurationModifier

        public ServerPagesBundle.ViewsBuilder viewsConfigurationModifier​(java.lang.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