Class TemplateView

  • Direct Known Subclasses:
    ErrorTemplateView

    public class TemplateView
    extends io.dropwizard.views.View
    View template rendering model. Must be used as base class for models instead of pure View.

    Template name may be specified directly (within constructor) or automatically detected from Template resource annotation. If template path starts with "/" it's considered absolute and searched directly within classpath, otherwise template is considered relative to one of configured classpath locations. Note that Template annotation defines templates relative to annotated class.

    For error pages use ErrorTemplateView class.

    Since:
    22.10.2018
    • Constructor Summary

      Constructors 
      Constructor Description
      TemplateView()
      Template obtained from Template annotation on resource.
      TemplateView​(java.lang.String templatePath)
      If template name is null, it will be obtained from Template annotation on resource.
      TemplateView​(java.lang.String templatePath, java.nio.charset.Charset charset)
      If template name is null, it will be obtained from Template annotation on resource.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      TemplateContext getContext()
      Note that this object is the only way to get original request path because templates are always rendered in rest endpoints after server redirect.
      • Methods inherited from class io.dropwizard.views.View

        getCharset, getTemplateName
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TemplateView

        public TemplateView()
        Template obtained from Template annotation on resource.
      • TemplateView

        public TemplateView​(@Nullable
                            java.lang.String templatePath)
        If template name is null, it will be obtained from Template annotation on resource.
        Parameters:
        templatePath - template path or null (to use annotation value)
      • TemplateView

        public TemplateView​(@Nullable
                            java.lang.String templatePath,
                            @Nullable
                            java.nio.charset.Charset charset)
        If template name is null, it will be obtained from Template annotation on resource.
        Parameters:
        templatePath - template path or null (to use annotation value)
        charset - charset or null
    • Method Detail

      • getContext

        public TemplateContext getContext()
        Note that this object is the only way to get original request path because templates are always rendered in rest endpoints after server redirect.
        Returns:
        additional info about current template.