public class OutputJavaScriptContentModelElement extends DependencyDeferredContentTargetModelElement
The ContentModelElement associated with the OutputJavaScriptDirective that is
used to flush out all <script> elements.
| Constructor and Description |
|---|
OutputJavaScriptContentModelElement(String id,
String directiveName,
DependencyAggregator dependencyAggregator,
WebFrameworkConfigElement webFrameworkConfig) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addInlineJavaScriptForAggregation(String script,
String groupName)
Adds raw JavaScript into the dependency list (so that order is preserved) by prefixing the code
with illegal path characters.
|
void |
addJavaScriptFile(String fileName,
String groupName,
boolean forAggregation)
Handles adding JavaScript dependencies and inline script content.
|
protected void |
addJavaScriptFile(String fileName,
String groupName,
LinkedHashMap<String,LinkedHashSet<String>> files)
Use this method to add a new JavaScript file to the list of dependencies
to be imported.
|
void |
addNonAmdJavaScriptFile(String fileName,
String group)
The Dojo generated non AMD JavaScript dependencies need to be handled separately from the those provided by the <
@script> directive. |
protected void |
appendJavaScriptDependency(StringBuilder jsDeps,
String src,
String group)
Method for adding a single JavaScript dependency to the supplied String builder, e.g.
|
protected LinkedHashMap<String,LinkedHashSet<String>> |
filterJsDependencies(LinkedHashMap<String,LinkedHashSet<String>> files)
Processes the supplied
LinkedHashMap to ensure that any dependencies that have been previously
requested are removed. |
String |
flushContent()
This method will be called when the
ExtensibilityModel containing
this ContentModelElement is closed. |
protected StringBuilder |
generateJavaScriptDependencies(HashMap<String,LinkedHashSet<String>> dependencies,
boolean aggregate)
Generates the complete list of JavaScript dependencies (including raw script inserts)
into a
StringBuilder which can then be output to the output stream. |
DependencyAggregator |
getDependencyAggregator() |
LinkedHashMap<String,LinkedHashSet<String>> |
getDojoNonAmdFiles() |
String |
getRequestPrefix() |
protected String |
getResourceControllerMapping()
This method must be implemented to return the mapping to the resource controller, e.g.
|
String |
getType() |
WebFrameworkConfigElement |
getWebFrameworkConfig() |
dependencyAlreadyRequested, enterEditMode, exitEditMode, getSourceElements, markDependencyAsRequested, normaliseDependency, registerDeferredSourceElementequals, getNextContentBufferElement, hashCode, parseContent, validateContentgetDirectiveName, getId, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitpublic OutputJavaScriptContentModelElement(String id, String directiveName, DependencyAggregator dependencyAggregator, WebFrameworkConfigElement webFrameworkConfig)
protected String getResourceControllerMapping()
DependencyDeferredContentTargetModelElementThis method must be implemented to return the mapping to the resource controller, e.g. "/share/res/"
getResourceControllerMapping in class DependencyDeferredContentTargetModelElementpublic String getType()
getType in interface org.springframework.extensions.surf.extensibility.ExtensibilityModelElementgetType in class org.springframework.extensions.surf.extensibility.impl.DefaultContentModelElementpublic LinkedHashMap<String,LinkedHashSet<String>> getDojoNonAmdFiles()
public void addJavaScriptFile(String fileName, String groupName, boolean forAggregation)
fileName - StringgroupName - StringforAggregation - booleanprotected void addJavaScriptFile(String fileName, String groupName, LinkedHashMap<String,LinkedHashSet<String>> files)
Use this method to add a new JavaScript file to the list of dependencies to be imported.
fileName - The filename of the JavaScript dependency.groupName - The group to add the JavaScript dependency to (passing a groupName of null
effectively assigns the dependency to the default group).public void addNonAmdJavaScriptFile(String fileName, String group)
@script> directive.
The reason for this is that Dojo dependencies get added as soon as they are encountered but the <@link> directive
dependencies only get added after all extensions have finished processing (this is so that the DeferredContentSourceModelElement
instances can be manipulated to add/remove/change dependency requests). However, we want to only output Dojo dependencies
if they have not requested via a <@script> directive.fileName - Stringgroup - Stringprotected void addInlineJavaScriptForAggregation(String script, String groupName)
Adds raw JavaScript into the dependency list (so that order is preserved) by prefixing the code
with illegal path characters. These characters can be detected by the DependencyHandler and
used to create a new script block with the contents.
script - The raw JavaScript to insert.groupName - The name of the group. This is important when dependency aggregation is enabled as
it ensures that the code is inserted into the correct resource.protected LinkedHashMap<String,LinkedHashSet<String>> filterJsDependencies(LinkedHashMap<String,LinkedHashSet<String>> files)
LinkedHashMap to ensure that any dependencies that have been previously
requested are removed.files - The LinkedHashMap of files to filterLinkedHashMappublic String flushContent()
This method will be called when the ExtensibilityModel containing
this ContentModelElement is closed. At this point any nested
models will have already added their required JavaScript dependencies and
<script> elements added.
flushContent in interface org.springframework.extensions.surf.extensibility.ContentModelElementflushContent in class org.springframework.extensions.surf.extensibility.impl.DefaultContentModelElementprotected StringBuilder generateJavaScriptDependencies(HashMap<String,LinkedHashSet<String>> dependencies, boolean aggregate)
Generates the complete list of JavaScript dependencies (including raw script inserts)
into a StringBuilder which can then be output to the output stream. If Surf is
running in dependency aggregation mode then this work is deleted to the DependencyAggregator
otherwise it is handled within the method.
dependencies - The dependencies to create the correct output for.protected void appendJavaScriptDependency(StringBuilder jsDeps, String src, String group)
Method for adding a single JavaScript dependency to the supplied String builder, e.g.
<script type="text/javascript" src="src"></script>
jsDeps - StringBuildersrc - Stringgroup - Stringpublic WebFrameworkConfigElement getWebFrameworkConfig()
public String getRequestPrefix()
public DependencyAggregator getDependencyAggregator()
Copyright © 2005–2016 Alfresco Software. All rights reserved.