Class TemplateRedirect

java.lang.Object
ru.vyarus.guicey.gsp.app.filter.redirect.TemplateRedirect

public class TemplateRedirect extends Object
Performs redirection of template request into rest context. Note that even if no special rest mapped for template, but request looks like direct file template, it would be rendered with the DirectTemplateExceptionMapper.

Rest resource convention: /[rest context]/[prefix]/[path from request], where [prefix] is application registration name by default (but may be configured). Additional mappings may be configured to sub url, so redirection to different rest "branches" may be performed, depending on called url.

If resource is annotated with Template annotation (it should!) then TemplateAnnotationFilter will detect it and set specified template into context TemplateContext.

Important: resources must use TemplateView as base template model class in order to properly support Template annotation.

Since:
03.12.2018
  • Constructor Details

  • Method Details

    • setRootPath

      public void setRootPath(String contextPath, String servletMapping)
      Parameters:
      contextPath - main context mapping path
      servletMapping - rest servlet mapping path
    • redirect

      public void redirect(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String page, io.dropwizard.views.common.ViewRenderer directTemplateRenderer) throws IOException, jakarta.servlet.ServletException
      Redirect template request into rest resource. Jersey will select appropriate resource by path, or thrown not found exception, received by DirectTemplateExceptionMapper (to render direct template instead).
      Parameters:
      request - template request
      response - template response
      page - requested template path (cleared for matching)
      directTemplateRenderer - vue renderer, recognized template or null
      Throws:
      IOException - on dispatching errors
      jakarta.servlet.ServletException - on dispatching errors
    • getErrorRedirect

      public ErrorRedirect getErrorRedirect()
      Returns:
      custom error pages support
    • getRootPath

      public String getRootPath()
      Returns:
      root rest mapping path
    • templateContext

      public static TemplateContext templateContext()
      Returns:
      thread bound template context or null