Class UncacheableDataProcessor

java.lang.Object
org.broadleafcommerce.presentation.dialect.AbstractBroadleafTagReplacementProcessor
org.broadleafcommerce.core.web.processor.UncacheableDataProcessor
All Implemented Interfaces:
org.broadleafcommerce.presentation.dialect.BroadleafProcessor, org.broadleafcommerce.presentation.dialect.BroadleafTagReplacementProcessor

@Component("blUncacheableDataProcessor") @ConditionalOnTemplating public class UncacheableDataProcessor extends org.broadleafcommerce.presentation.dialect.AbstractBroadleafTagReplacementProcessor
This processor outputs a SCRIPT tag with JSON data that can be used to update a mostly cached page followed by a call to a javascript function. The function name is "updateUncacheableData()" by default.

Broadleaf provides this example but most clients with typical customizations will need to create a similar processor to meet their dynamic data caching needs.

The Broadleaf processor works with the sample javacript function in HeatClinic found in heatClinic-UncacheableData.js work together to update the "In Cart", "Out of Stock", "Welcome {name}", and "Cart Qty" messages. By doing this, the category and product pages in HeatClinic can be aggressively cached using the BroadleafCacheProcessor.

Example usage on cached pages with dynamic data. This would generally go after the footer for the page.

  
      <blc:uncacheableData />
  
 
Author:
bpolster
  • Field Details

  • Constructor Details

    • UncacheableDataProcessor

      public UncacheableDataProcessor()
  • Method Details

    • getName

      public String getName()
    • getPrecedence

      public int getPrecedence()
      Specified by:
      getPrecedence in interface org.broadleafcommerce.presentation.dialect.BroadleafProcessor
      Overrides:
      getPrecedence in class org.broadleafcommerce.presentation.dialect.AbstractBroadleafTagReplacementProcessor
    • getReplacementModel

      public org.broadleafcommerce.presentation.model.BroadleafTemplateModel getReplacementModel(String tagName, Map<String,String> tagAttributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context)
    • buildContentMap

      protected String buildContentMap(org.broadleafcommerce.presentation.model.BroadleafTemplateContext context)
    • addProductInventoryData

      protected void addProductInventoryData(Map<String,Object> attrMap, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context)
    • defineOutOfStockProducts

      protected void defineOutOfStockProducts(org.broadleafcommerce.presentation.model.BroadleafTemplateContext context, Set<Product> allProducts, Set<Long> outOfStockProducts)
    • isBlockingAvailabilityOfProduct

      protected boolean isBlockingAvailabilityOfProduct(Product baseProduct, Product product)
    • isBundle

      protected boolean isBundle(Product product)
    • addCartData

      protected void addCartData(Map<String,Object> attrMap)
    • addCustomerData

      protected void addCustomerData(Map<String,Object> attrMap)
    • getUncacheableDataFunction

      public String getUncacheableDataFunction(org.broadleafcommerce.presentation.model.BroadleafTemplateContext context, Map<String,String> tagAttributes)
    • getDefaultCallbackFunction

      public String getDefaultCallbackFunction()
    • setDefaultCallbackFunction

      public void setDefaultCallbackFunction(String defaultCallbackFunction)