Class ServerPagesBundle.ViewsBuilder
- Enclosing class:
- ServerPagesBundle
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddViewRenderers(io.dropwizard.views.common.ViewRenderer... renderers) Additional view renderers (template engines support) to use forViewBundleconfiguration.build()Configures custom freemarkerTemplateLoaderso freemarker could also see templates declared in custom class loaders.Prints configuration object used for dropwizard views bundle (ViewBundle).<T extends io.dropwizard.core.Configuration>
ServerPagesBundle.ViewsBuilderviewsConfiguration(io.dropwizard.views.common.ViewConfigurable<T> configurable) Configures configuration provider forViewBundle(usually mapping from yaml configuration).viewsConfigurationModifier(String name, ViewRendererConfigurationModifier modifier) Dropwizard views configuration modification.
-
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 forViewBundleconfiguration. 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 forViewBundle(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:
-
ViewBundle.getViewConfiguration(Object)viewsConfigurationModifier(String, ViewRendererConfigurationModifier)printViewsConfiguration()
-
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
Prints configuration object used for dropwizard views bundle (ViewBundle). Note that initial views configuration object binding is configured withviewsConfiguration(ViewConfigurable)and it could be modified withviewsConfigurationModifier(String, ViewRendererConfigurationModifier). Printing of the final configuration (after all modification) could be useful for debugging.- Returns:
- builder instance for chained calls
-
enableFreemarkerCustomClassLoadersSupport
Configures custom freemarkerTemplateLoaderso freemarker could also see templates declared in custom class loaders.- Returns:
- builder instance for chained calls
- See Also:
-
build
- Returns:
- configured bundle instance
-