org.broadleafcommerce.common.web
Class BroadleafThymeleafViewResolver

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
          extended by org.springframework.web.servlet.view.AbstractCachingViewResolver
              extended by org.thymeleaf.spring3.view.ThymeleafViewResolver
                  extended by org.broadleafcommerce.common.web.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.spring3.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)

Field Summary
static String AJAX_REDIRECT_URL_PREFIX
           Prefix to be used in view names (returned by controllers) for specifying an HTTP redirect with AJAX support.
protected  String fullPageLayout
           
protected  String iframeLayout
           
protected  Map<String,String> layoutMap
           
 
Fields inherited from class org.thymeleaf.spring3.view.ThymeleafViewResolver
FORWARD_URL_PREFIX, REDIRECT_URL_PREFIX
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
BroadleafThymeleafViewResolver()
           
 
Method Summary
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.
 String getFullPageLayout()
          The default layout to use if there is no specifc entry in the layout map
 String getIframeLayout()
          The layout to use for iframe requests
 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
protected  boolean isAjaxRequest()
           
protected  boolean isIFrameRequest()
           
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)
           
 void setFullPageLayout(String fullPageLayout)
           
 void setIframeLayout(String iframeLayout)
           
 void setLayoutMap(Map<String,String> layoutMap)
           
 
Methods inherited from class org.thymeleaf.spring3.view.ThymeleafViewResolver
addStaticVariable, canHandle, getCharacterEncoding, getContentType, getExcludedViewNames, getOrder, getStaticVariables, getTemplateEngine, getViewClass, getViewNames, isRedirectContextRelative, isRedirectHttp10Compatible, setCharacterEncoding, setContentType, setExcludedViewNames, setOrder, setRedirectContextRelative, setRedirectHttp10Compatible, setStaticVariables, setTemplateEngine, setViewClass, setViewNames
 
Methods inherited from class org.springframework.web.servlet.view.AbstractCachingViewResolver
clearCache, getCacheKey, isCache, isCacheUnresolved, removeFromCache, resolveViewName, setCache, 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, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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:
Constant Field Values

layoutMap

protected Map<String,String> layoutMap

fullPageLayout

protected String fullPageLayout

iframeLayout

protected String iframeLayout
Constructor Detail

BroadleafThymeleafViewResolver

public BroadleafThymeleafViewResolver()
Method Detail

canHandle

protected boolean canHandle(String viewName)

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

loadView

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

isIFrameRequest

protected boolean isIFrameRequest()

isAjaxRequest

protected boolean isAjaxRequest()

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:
getLayoutMap()

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:
getFullPageLayout()

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:
getIframeLayout()


Copyright © 2013. All Rights Reserved.