org.apache.tapestry5.internal.services
Class DocumentLinkerImpl

java.lang.Object
  extended by org.apache.tapestry5.internal.services.DocumentLinkerImpl
All Implemented Interfaces:
DocumentLinker

public class DocumentLinkerImpl
extends Object
implements DocumentLinker


Constructor Summary
DocumentLinkerImpl(boolean omitGeneratorMetaTag, String tapestryVersion, boolean compactJSON)
           
 
Method Summary
protected  void addDynamicScriptBlock(Element body)
          Adds the dynamic script block, which is, ultimately, a call to the client-side Tapestry.onDOMLoaded() function.
 void addScript(InitializationPriority priority, String script)
          Adds JavaScript code.
 void addScriptLink(String scriptURL)
          Adds a link to load a JavaScript library.
protected  void addScriptLinksForIncludedScripts(Element headElement, List<String> scripts)
          Adds a script link for each included script to the top of the the <head> element.
 void addStylesheetLink(StylesheetLink sheet)
          Adds a link to load a CSS stylesheet.
protected  void addStylesheetsToHead(Element root, List<StylesheetLink> stylesheets)
          Locates the head element under the root ("html") element, creating it if necessary, and adds the stylesheets to it.
 void setInitialization(InitializationPriority priority, JSONObject initialization)
          Adds a call to the Tapestry.init() function.
 void updateDocument(Document document)
          Updates the supplied Document, possibly adding <head> or <body> elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentLinkerImpl

public DocumentLinkerImpl(boolean omitGeneratorMetaTag,
                          String tapestryVersion,
                          boolean compactJSON)
Parameters:
omitGeneratorMetaTag - via symbol configuration
tapestryVersion - version of Tapestry framework (for meta tag)
compactJSON - should JSON content be compact or pretty printed?
Method Detail

addStylesheetLink

public void addStylesheetLink(StylesheetLink sheet)
Description copied from interface: DocumentLinker
Adds a link to load a CSS stylesheet.

Specified by:
addStylesheetLink in interface DocumentLinker

addScriptLink

public void addScriptLink(String scriptURL)
Description copied from interface: DocumentLinker
Adds a link to load a JavaScript library. . The <script> elements will be added inside the document's <head>.

Specified by:
addScriptLink in interface DocumentLinker

addScript

public void addScript(InitializationPriority priority,
                      String script)
Description copied from interface: DocumentLinker
Adds JavaScript code. The code is collected into a single block that is injected just before the close body tag of the page (in a full page render) and collected as the "script" property of the partial page render response. The JavaScript is executed after the page loads (or in an Ajax update, after external JavaScript libraries are loaded and the DOM is updated).

This method may be called multiple times for the same priority and the script will be accumulated.

Specified by:
addScript in interface DocumentLinker
Parameters:
priority - when to execute the provided script
script - statement to add to the block (a newline will be appended as well)

setInitialization

public void setInitialization(InitializationPriority priority,
                              JSONObject initialization)
Description copied from interface: DocumentLinker
Adds a call to the Tapestry.init() function. This may be called multiple times and the init() calls will occur in order. In a normal page render, the init() calls will be added to the main JavaScript block, but in a partial page render Ajax response, the initialization will be property "init" of the partial page render response.

This method should only be invoked at most once per priority.

Specified by:
setInitialization in interface DocumentLinker

updateDocument

public void updateDocument(Document document)
Updates the supplied Document, possibly adding <head> or <body> elements.

Parameters:
document - to be updated

addDynamicScriptBlock

protected void addDynamicScriptBlock(Element body)
Adds the dynamic script block, which is, ultimately, a call to the client-side Tapestry.onDOMLoaded() function.

Parameters:
body - element to add the dynamic scripting to

addScriptLinksForIncludedScripts

protected void addScriptLinksForIncludedScripts(Element headElement,
                                                List<String> scripts)
Adds a script link for each included script to the top of the the <head> element. The new elements are inserted just before the first <script> tag, or appended at the end.

Parameters:
headElement - element to add the script links to
scripts - scripts URLs to add as <script> elements

addStylesheetsToHead

protected void addStylesheetsToHead(Element root,
                                    List<StylesheetLink> stylesheets)
Locates the head element under the root ("html") element, creating it if necessary, and adds the stylesheets to it.

Parameters:
root - element of document
stylesheets - to add to the document


Copyright © 2003-2012 The Apache Software Foundation.