public class JavaScriptDependencyDirective extends AbstractDependencyExtensibilityDirective
This directive is used to address the problem of browsers caching stale JavaScript resources. It modifies the source file requested to include an MD5 checksum generated from the file contents to ensure that when a file is updated the browser will be forced to request the updated version (because the browser cached version will be stored against a different URL).
AbstractDependencyExtensibilityDirective.ProcessedDependency| Modifier and Type | Field and Description |
|---|---|
static String |
FORCE_AGGREGATED_OUTPUT_PARAM |
dependencyAggregator, dependencyHandler| Constructor and Description |
|---|
JavaScriptDependencyDirective(String directiveName,
org.springframework.extensions.surf.extensibility.ExtensibilityModel model) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addLegacyDependencyRequest(Map params)
Provides support for making dependency requests when there isn't a
DeferredContentTargetModelElement to
add content to. |
protected DependencyDirectiveData |
createDependencyDirectiveData(String id,
String action,
String target,
Map params,
freemarker.template.TemplateDirectiveBody body,
freemarker.core.Environment env,
String dependencyToAdd,
String group)
Creates the
DependencyDirectiveData. |
org.springframework.extensions.surf.extensibility.ExtensibilityDirectiveData |
createExtensibilityDirectiveData(String id,
String action,
String target,
Map params,
freemarker.template.TemplateDirectiveBody body,
freemarker.core.Environment env) |
void |
execute(freemarker.core.Environment env,
Map params,
freemarker.template.TemplateModel[] loopVars,
freemarker.template.TemplateDirectiveBody body) |
protected String |
getDependencySource(Map params)
Gets the parameter that defines the dependency source file.
|
protected org.springframework.extensions.surf.extensibility.DeferredContentTargetModelElement |
getTargetElement()
Gets the
DeferredContentTargetModelElement to associate with the directive. |
getModelObject, getRequestContext, getResourceControllerMapping, getToInsert, getUpdatedSrc, getWebFrameworkConfig, processDependency, setDependencyAggregator, setDependencyHandler, setModelObject, setRequestContext, setWebFrameworkConfigafter, before, getId, getModel, merge, remove, replacepublic static final String FORCE_AGGREGATED_OUTPUT_PARAM
public JavaScriptDependencyDirective(String directiveName, org.springframework.extensions.surf.extensibility.ExtensibilityModel model)
public void execute(freemarker.core.Environment env,
Map params,
freemarker.template.TemplateModel[] loopVars,
freemarker.template.TemplateDirectiveBody body)
throws freemarker.template.TemplateException,
IOException
execute in interface freemarker.template.TemplateDirectiveModelexecute in class org.springframework.extensions.surf.extensibility.impl.AbstractExtensibilityDirectivefreemarker.template.TemplateExceptionIOExceptionprotected void addLegacyDependencyRequest(Map params) throws freemarker.template.TemplateModelException
Provides support for making dependency requests when there isn't a DeferredContentTargetModelElement to
add content to. This will occur when processing the .head.ftl files of a WebScript and is considered the "legacy"
approach to making dependency requests. The preferred approach is to move the requests to the *.html.ftl file and
use the new <@script> and <@link> directive implementations.
params - Mapfreemarker.template.TemplateModelExceptionprotected String getDependencySource(Map params) throws freemarker.template.TemplateModelException
Gets the parameter that defines the dependency source file. By default this is "src".
params - The map of parameters to search through.freemarker.template.TemplateModelException - When the target parameter cannot be found.protected org.springframework.extensions.surf.extensibility.DeferredContentTargetModelElement getTargetElement()
Gets the DeferredContentTargetModelElement to associate with the directive. By default this is the
OutputJavaScriptContentModelElement.
public org.springframework.extensions.surf.extensibility.ExtensibilityDirectiveData createExtensibilityDirectiveData(String id, String action, String target, Map params, freemarker.template.TemplateDirectiveBody body, freemarker.core.Environment env) throws freemarker.template.TemplateException
createExtensibilityDirectiveData in class org.springframework.extensions.surf.extensibility.impl.AbstractExtensibilityDirectivefreemarker.template.TemplateExceptionprotected DependencyDirectiveData createDependencyDirectiveData(String id, String action, String target, Map params, freemarker.template.TemplateDirectiveBody body, freemarker.core.Environment env, String dependencyToAdd, String group) throws freemarker.template.TemplateModelException
Creates the DependencyDirectiveData.
id - Stringaction - Stringtarget - Stringparams - Mapbody - TemplateDirectiveBodyenv - EnvironmentdependencyToAdd - Stringgroup - Stringfreemarker.template.TemplateModelExceptionCopyright © 2005–2016 Alfresco Software. All rights reserved.