Class TemplateRedirect
- java.lang.Object
-
- ru.vyarus.guicey.gsp.app.filter.redirect.TemplateRedirect
-
public class TemplateRedirect extends java.lang.ObjectPerforms 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 theDirectTemplateExceptionMapper.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
Templateannotation (it should!) thenTemplateAnnotationFilterwill detect it and set specified template into contextTemplateContext.Important: resources must use
TemplateViewas base template model class in order to properly supportTemplateannotation.- Since:
- 03.12.2018
-
-
Constructor Summary
Constructors Constructor Description TemplateRedirect(javax.servlet.Servlet restServlet, java.lang.String app, java.lang.String mapping, ViewRestLookup views, AssetLookup assets, ErrorRedirect errorRedirect)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ErrorRedirectgetErrorRedirect()java.lang.StringgetRootPath()voidredirect(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String page, io.dropwizard.views.common.ViewRenderer directTemplateRenderer)Redirect template request into rest resource.voidsetRootPath(java.lang.String contextPath, java.lang.String servletMapping)static TemplateContexttemplateContext()
-
-
-
Constructor Detail
-
TemplateRedirect
public TemplateRedirect(javax.servlet.Servlet restServlet, java.lang.String app, java.lang.String mapping, ViewRestLookup views, AssetLookup assets, ErrorRedirect errorRedirect)
-
-
Method Detail
-
setRootPath
public void setRootPath(java.lang.String contextPath, java.lang.String servletMapping)- Parameters:
contextPath- main context mapping pathservletMapping- rest servlet mapping path
-
redirect
public void redirect(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String page, io.dropwizard.views.common.ViewRenderer directTemplateRenderer) throws java.io.IOException, javax.servlet.ServletExceptionRedirect template request into rest resource. Jersey will select appropriate resource by path, or thrown not found exception, received byDirectTemplateExceptionMapper(to render direct template instead).- Parameters:
request- template requestresponse- template responsepage- requested template path (cleared for matching)directTemplateRenderer- vue renderer, recognized template or null- Throws:
java.io.IOException- on dispatching errorsjavax.servlet.ServletException- on dispatching errors
-
getErrorRedirect
public ErrorRedirect getErrorRedirect()
- Returns:
- custom error pages support
-
getRootPath
public java.lang.String getRootPath()
- Returns:
- root rest mapping path
-
templateContext
public static TemplateContext templateContext()
- Returns:
- thread bound template context or null
-
-