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
FieldsModifier and TypeFieldDescriptionstatic final StringPrefix to be used in view names (returned by controllers) for specifying an HTTP redirect with AJAX support.static final Stringprotected org.broadleafcommerce.common.web.BroadleafTemplateViewResolverExtensionManagerprotected Stringprotected StringFields inherited from class org.thymeleaf.spring6.view.ThymeleafViewResolver
FORWARD_URL_PREFIX, REDIRECT_URL_PREFIXFields inherited from class org.springframework.web.servlet.view.AbstractCachingViewResolver
DEFAULT_CACHE_LIMITFields inherited from class org.springframework.context.support.ApplicationObjectSupport
loggerFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected org.springframework.web.servlet.ViewcreateView(String viewName, Locale locale) Determines which internal method to call for creating the appropriate view.protected ObjectgetCacheKey(String viewName, Locale locale) protected org.springframework.web.context.request.WebRequestThe default layout to use if there is no specifc entry in the layout mapThe layout to use for iframe requestsGets the map of prefix : layout for use in determining which layout to dispatch the request to in non-AJAX callsprotected voidinitializeAjaxRedirectFlashmap(String redirectUrl) Sets up the Spring MVC FlashMap to replicate what happens when you return "redirect:" from a Spring controller.protected booleanprotected booleanprotected org.springframework.web.servlet.ViewloadAjaxRedirectView(String redirectUrl, Locale locale) Performs a Broadleaf AJAX redirect.protected org.springframework.web.servlet.Vieworg.springframework.web.servlet.ViewresolveViewName(String viewName, Locale locale) voidsetFullPageLayout(String fullPageLayout) voidsetIframeLayout(String iframeLayout) voidsetLayoutMap(Map<String, String> layoutMap) protected booleanMethods 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, setViewNamesMethods inherited from class org.springframework.web.servlet.view.AbstractCachingViewResolver
clearCache, getCacheFilter, getCacheLimit, isCache, isCacheUnresolved, removeFromCache, setCache, setCacheFilter, setCacheLimit, setCacheUnresolvedMethods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContextMethods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContext
-
Field Details
-
extensionManager
protected org.broadleafcommerce.common.web.BroadleafTemplateViewResolverExtensionManager extensionManager -
EXTENSION_TEMPLATE_ATTR_NAME
- See Also:
-
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
-
fullPageLayout
-
iframeLayout
-
-
Constructor Details
-
BroadleafThymeleafViewResolver
public BroadleafThymeleafViewResolver()
-
-
Method Details
-
useThymeleafLayoutDialect
protected boolean useThymeleafLayoutDialect() -
canHandle
-
resolveViewName
public org.springframework.web.servlet.View resolveViewName(String viewName, Locale locale) throws Exception - Specified by:
resolveViewNamein interfaceorg.springframework.web.servlet.ViewResolver- Overrides:
resolveViewNamein classorg.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:
createViewin classorg.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
Sets up the Spring MVC FlashMap to replicate what happens when you return "redirect:" from a Spring controller. This code comes directly fromRedirectView.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:
loadViewin classorg.thymeleaf.spring6.view.ThymeleafViewResolver- Throws:
Exception
-
getCacheKey
- Overrides:
getCacheKeyin classorg.springframework.web.servlet.view.AbstractCachingViewResolver
-
isIFrameRequest
protected boolean isIFrameRequest() -
isAjaxRequest
protected boolean isAjaxRequest() -
getCurrentRequest
protected org.springframework.web.context.request.WebRequest getCurrentRequest() -
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
- Parameters:
layoutMap-- See Also:
-
getFullPageLayout
The default layout to use if there is no specifc entry in the layout map- Returns:
- the full page layout
-
setFullPageLayout
- Parameters:
fullPageLayout-- See Also:
-
getIframeLayout
The layout to use for iframe requests- Returns:
- the iframe layout
-
setIframeLayout
- Parameters:
iframeLayout-- See Also:
-