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 Summary
FieldsModifier and TypeFieldDescriptionprotected org.broadleafcommerce.common.security.service.ExploitProtectionServiceprotected UncacheableDataProcessorExtensionManagerprotected org.broadleafcommerce.core.inventory.service.InventoryServiceprotected org.broadleafcommerce.core.inventory.service.InventoryServiceExtensionManagerFields inherited from interface org.broadleafcommerce.presentation.dialect.BroadleafProcessor
DEFAULT_PRECEDENCE, DEFAULT_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCartData(Map<String, Object> attrMap) protected voidaddCustomerData(Map<String, Object> attrMap) protected voidaddProductInventoryData(Map<String, Object> attrMap, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) protected StringbuildContentMap(org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) protected voiddefineOutOfStockProducts(org.broadleafcommerce.presentation.model.BroadleafTemplateContext context, Set<org.broadleafcommerce.core.catalog.domain.Product> allProducts, Set<Long> outOfStockProducts) getName()intorg.broadleafcommerce.presentation.model.BroadleafTemplateModelgetReplacementModel(String tagName, Map<String, String> tagAttributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) getUncacheableDataFunction(org.broadleafcommerce.presentation.model.BroadleafTemplateContext context, Map<String, String> tagAttributes) protected booleanisBlockingAvailabilityOfProduct(org.broadleafcommerce.core.catalog.domain.Product baseProduct, org.broadleafcommerce.core.catalog.domain.Product product) protected booleanisBundle(org.broadleafcommerce.core.catalog.domain.Product product) voidsetDefaultCallbackFunction(String defaultCallbackFunction) Methods inherited from class org.broadleafcommerce.presentation.dialect.AbstractBroadleafTagReplacementProcessor
getPrefix, replacementNeedsProcessing
-
Field Details
-
inventoryService
protected org.broadleafcommerce.core.inventory.service.InventoryService inventoryService -
eps
protected org.broadleafcommerce.common.security.service.ExploitProtectionService eps -
extensionManager
-
inventoryServiceExtensionManager
protected org.broadleafcommerce.core.inventory.service.InventoryServiceExtensionManager inventoryServiceExtensionManager
-
-
Constructor Details
-
UncacheableDataProcessor
public UncacheableDataProcessor()
-
-
Method Details
-
getName
-
getPrecedence
public int getPrecedence()- Specified by:
getPrecedencein interfaceorg.broadleafcommerce.presentation.dialect.BroadleafProcessor- Overrides:
getPrecedencein classorg.broadleafcommerce.presentation.dialect.AbstractBroadleafTagReplacementProcessor
-
getReplacementModel
-
buildContentMap
protected String buildContentMap(org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) -
addProductInventoryData
-
defineOutOfStockProducts
-
isBlockingAvailabilityOfProduct
protected boolean isBlockingAvailabilityOfProduct(org.broadleafcommerce.core.catalog.domain.Product baseProduct, org.broadleafcommerce.core.catalog.domain.Product product) -
isBundle
protected boolean isBundle(org.broadleafcommerce.core.catalog.domain.Product product) -
addCartData
-
addCustomerData
-
getUncacheableDataFunction
-
getDefaultCallbackFunction
-
setDefaultCallbackFunction
-