public static class ServerPagesBundle.ViewsBuilder
extends java.lang.Object
| Constructor and Description |
|---|
ViewsBuilder() |
| Modifier and Type | Method and Description |
|---|---|
ServerPagesBundle.ViewsBuilder |
addViewRenderers(io.dropwizard.views.ViewRenderer... renderers)
Additional view renderers (template engines support) to use for
ViewBundle configuration. |
ServerPagesBundle |
build() |
ServerPagesBundle.ViewsBuilder |
printViewsConfiguration()
Prints configuration object used for dropwizard views bundle (
ViewBundle). |
<T extends io.dropwizard.Configuration> |
viewsConfiguration(io.dropwizard.views.ViewConfigurable<T> configurable)
Configures configuration provider for
ViewBundle (usually mapping from yaml configuration). |
ServerPagesBundle.ViewsBuilder |
viewsConfigurationModifier(java.lang.String name,
ViewRendererConfigurationModifier modifier)
Dropwizard views configuration modification.
|
public ServerPagesBundle.ViewsBuilder addViewRenderers(io.dropwizard.views.ViewRenderer... renderers)
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).
renderers - renderers to use for global dropwizard views configurationViewBundle.ViewBundle(Iterable)public <T extends io.dropwizard.Configuration> ServerPagesBundle.ViewsBuilder viewsConfiguration(io.dropwizard.views.ViewConfigurable<T> configurable)
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.
T - configuration object typeconfigurable - views configuration lookup.ViewBundle.getViewConfiguration(Object),
viewsConfigurationModifier(String, ViewRendererConfigurationModifier),
printViewsConfiguration()public ServerPagesBundle.ViewsBuilder viewsConfigurationModifier(java.lang.String name, ViewRendererConfigurationModifier modifier)
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.
name - renderer name (e.g. freemarker, mustache, etc.)modifier - modification callbackpublic ServerPagesBundle.ViewsBuilder printViewsConfiguration()
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.public ServerPagesBundle build()