Class TemplateView

java.lang.Object
io.dropwizard.views.common.View
ru.vyarus.guicey.gsp.views.template.TemplateView
Direct Known Subclasses:
ErrorTemplateView

public class TemplateView extends io.dropwizard.views.common.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 Details

    • TemplateView

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

      public TemplateView(@Nullable 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 String templatePath, @Nullable 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 Details

    • 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.