Class BroadleafThymeleafViewResolver

java.lang.Object
org.springframework.context.support.ApplicationObjectSupport
org.springframework.web.context.support.WebApplicationObjectSupport
org.springframework.web.servlet.view.AbstractCachingViewResolver
org.thymeleaf.spring6.view.ThymeleafViewResolver
org.broadleafcommerce.presentation.thymeleaf3.BroadleafThymeleafViewResolver
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.core.Ordered, org.springframework.web.context.ServletContextAware, org.springframework.web.servlet.ViewResolver

public class BroadleafThymeleafViewResolver extends org.thymeleaf.spring6.view.ThymeleafViewResolver
This class extends the default ThymeleafViewResolver to facilitate rendering template fragments (such as those used by AJAX modals or iFrames) within a full page container should the request for that template have occurred in a stand-alone context.
Author:
Andre Azzolini (apazzolini)
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.springframework.web.servlet.view.AbstractCachingViewResolver

    org.springframework.web.servlet.view.AbstractCachingViewResolver.CacheFilter
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Prefix to be used in view names (returned by controllers) for specifying an HTTP redirect with AJAX support.
    static final String
     
    protected org.broadleafcommerce.common.web.BroadleafTemplateViewResolverExtensionManager
     
    protected String
     
    protected String
     
    protected Map<String,String>
     

    Fields inherited from class org.thymeleaf.spring6.view.ThymeleafViewResolver

    FORWARD_URL_PREFIX, REDIRECT_URL_PREFIX

    Fields inherited from class org.springframework.web.servlet.view.AbstractCachingViewResolver

    DEFAULT_CACHE_LIMIT

    Fields inherited from class org.springframework.context.support.ApplicationObjectSupport

    logger

    Fields inherited from interface org.springframework.core.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    canHandle(String viewName)
     
    protected org.springframework.web.servlet.View
    createView(String viewName, Locale locale)
    Determines which internal method to call for creating the appropriate view.
    protected Object
    getCacheKey(String viewName, Locale locale)
     
    protected org.springframework.web.context.request.WebRequest
     
    The default layout to use if there is no specifc entry in the layout map
    The layout to use for iframe requests
    Gets the map of prefix : layout for use in determining which layout to dispatch the request to in non-AJAX calls
    protected void
    Sets up the Spring MVC FlashMap to replicate what happens when you return "redirect:" from a Spring controller.
    protected boolean
     
    protected boolean
     
    protected org.springframework.web.servlet.View
    loadAjaxRedirectView(String redirectUrl, Locale locale)
    Performs a Broadleaf AJAX redirect.
    protected org.springframework.web.servlet.View
    loadView(String originalViewName, Locale locale)
     
    org.springframework.web.servlet.View
    resolveViewName(String viewName, Locale locale)
     
    void
    setFullPageLayout(String fullPageLayout)
     
    void
    setIframeLayout(String iframeLayout)
     
    void
     
    protected boolean
     

    Methods inherited from class org.thymeleaf.spring6.view.ThymeleafViewResolver

    addStaticVariable, canHandle, getAlwaysProcessRedirectAndForward, getCharacterEncoding, getContentType, getExcludedViewNames, getForceContentType, getOrder, getProducePartialOutputWhileProcessing, getStaticVariables, getTemplateEngine, getViewClass, getViewNames, isRedirectContextRelative, isRedirectHttp10Compatible, setAlwaysProcessRedirectAndForward, setCharacterEncoding, setContentType, setExcludedViewNames, setForceContentType, setOrder, setProducePartialOutputWhileProcessing, setRedirectContextRelative, setRedirectHttp10Compatible, setStaticVariables, setTemplateEngine, setViewClass, setViewNames

    Methods inherited from class org.springframework.web.servlet.view.AbstractCachingViewResolver

    clearCache, getCacheFilter, getCacheLimit, isCache, isCacheUnresolved, removeFromCache, setCache, setCacheFilter, setCacheLimit, setCacheUnresolved

    Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport

    getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext

    Methods inherited from class org.springframework.context.support.ApplicationObjectSupport

    getApplicationContext, getMessageSourceAccessor, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • extensionManager

      protected org.broadleafcommerce.common.web.BroadleafTemplateViewResolverExtensionManager extensionManager
    • EXTENSION_TEMPLATE_ATTR_NAME

      public static final String EXTENSION_TEMPLATE_ATTR_NAME
      See Also:
    • AJAX_REDIRECT_URL_PREFIX

      public static final String AJAX_REDIRECT_URL_PREFIX

      Prefix to be used in view names (returned by controllers) for specifying an HTTP redirect with AJAX support. That is, if you want a redirect to be followed by the browser as the result of an AJAX call or within an iFrame at the parent window, you can utilize this prefix. Note that this requires a JavaScript component, which is provided as part of BLC.js

      If the request was not performed in an AJAX / iFrame context, this method will delegate to the normal "redirect:" prefix.

      Value: ajaxredirect:

      See Also:
    • layoutMap

      protected Map<String,String> layoutMap
    • fullPageLayout

      protected String fullPageLayout
    • iframeLayout

      protected String iframeLayout
  • Constructor Details

    • BroadleafThymeleafViewResolver

      public BroadleafThymeleafViewResolver()
  • Method Details

    • useThymeleafLayoutDialect

      protected boolean useThymeleafLayoutDialect()
    • canHandle

      protected boolean canHandle(String viewName)
    • resolveViewName

      public org.springframework.web.servlet.View resolveViewName(String viewName, Locale locale) throws Exception
      Specified by:
      resolveViewName in interface org.springframework.web.servlet.ViewResolver
      Overrides:
      resolveViewName in class org.springframework.web.servlet.view.AbstractCachingViewResolver
      Throws:
      Exception
    • createView

      protected org.springframework.web.servlet.View createView(String viewName, Locale locale) throws Exception
      Determines which internal method to call for creating the appropriate view. If no Broadleaf specific methods match the viewName, it delegates to the parent ThymeleafViewResolver createView method
      Overrides:
      createView in class org.thymeleaf.spring6.view.ThymeleafViewResolver
      Throws:
      Exception
    • loadAjaxRedirectView

      protected org.springframework.web.servlet.View loadAjaxRedirectView(String redirectUrl, Locale locale) throws Exception
      Performs a Broadleaf AJAX redirect. This is used in conjunction with BLC.js to support doing a browser page change as as result of an AJAX call.
      Parameters:
      redirectUrl -
      locale -
      Returns:
      Throws:
      Exception
    • initializeAjaxRedirectFlashmap

      protected void initializeAjaxRedirectFlashmap(String redirectUrl)
      Sets up the Spring MVC FlashMap to replicate what happens when you return "redirect:" from a Spring controller. This code comes directly from RedirectView.renderMergedOutputModel(java.util.Map<java.lang.String, java.lang.Object>, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse)
      Parameters:
      redirectUrl - URL to redirect to
    • loadView

      protected org.springframework.web.servlet.View loadView(String originalViewName, Locale locale) throws Exception
      Overrides:
      loadView in class org.thymeleaf.spring6.view.ThymeleafViewResolver
      Throws:
      Exception
    • getCacheKey

      protected Object getCacheKey(String viewName, Locale locale)
      Overrides:
      getCacheKey in class org.springframework.web.servlet.view.AbstractCachingViewResolver
    • isIFrameRequest

      protected boolean isIFrameRequest()
    • isAjaxRequest

      protected boolean isAjaxRequest()
    • getCurrentRequest

      protected org.springframework.web.context.request.WebRequest getCurrentRequest()
    • getLayoutMap

      public Map<String,String> getLayoutMap()
      Gets the map of prefix : layout for use in determining which layout to dispatch the request to in non-AJAX calls
      Returns:
      the layout map
    • setLayoutMap

      public void setLayoutMap(Map<String,String> layoutMap)
      Parameters:
      layoutMap -
      See Also:
    • getFullPageLayout

      public String getFullPageLayout()
      The default layout to use if there is no specifc entry in the layout map
      Returns:
      the full page layout
    • setFullPageLayout

      public void setFullPageLayout(String fullPageLayout)
      Parameters:
      fullPageLayout -
      See Also:
    • getIframeLayout

      public String getIframeLayout()
      The layout to use for iframe requests
      Returns:
      the iframe layout
    • setIframeLayout

      public void setIframeLayout(String iframeLayout)
      Parameters:
      iframeLayout -
      See Also: