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 productionMode, boolean omitGeneratorMetaTag, String tapestryVersion, boolean combineScripts, String contextPath, ClientDataEncoder clientDataEncoder)
           
 
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(String script)
          Adds JavaScript code.
 void addScriptLink(String scriptURL)
          Adds a link to load a script.
protected  void addScriptLinksForIncludedScripts(Element container, List<String> scripts)
          Adds a script link for each included script to the bottom of the container (the <head>).
 void addStylesheetLink(String styleURL, String media)
          Adds a link to load a CSS stylesheet.
protected  void addStylesheetsToHead(Element root, List<org.apache.tapestry5.internal.services.IncludedStylesheet> stylesheets)
          Locates the head element under the root ("html") element, creating it if necessary, and adds the stylesheets to it.
 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 productionMode,
                          boolean omitGeneratorMetaTag,
                          String tapestryVersion,
                          boolean combineScripts,
                          String contextPath,
                          ClientDataEncoder clientDataEncoder)
Parameters:
productionMode - via symbol configuration
omitGeneratorMetaTag - via symbol configuration
tapestryVersion - version of Tapestry framework (for meta tag)
combineScripts - if true, individual JavaScript assets will be combined into a single virtual asset
contextPath - Request.getContextPath()
clientDataEncoder - used to encode data for the combined virtual asset
Method Detail

addStylesheetLink

public void addStylesheetLink(String styleURL,
                              String media)
Description copied from interface: DocumentLinker
Adds a link to load a CSS stylesheet. Stylesheets are loaded only once.

Specified by:
addStylesheetLink in interface DocumentLinker
Parameters:
styleURL - URL of stylesheet to load
media - media value (or null to omit the media attribute)

addScriptLink

public void addScriptLink(String scriptURL)
Description copied from interface: DocumentLinker
Adds a link to load a script. Scripts will be loaded only once. The <script> elements will be added at the top or bottom of the <body> element (the location is configurable).

Specified by:
addScriptLink in interface DocumentLinker

addScript

public void addScript(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.

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

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 container,
                                                List<String> scripts)
Adds a script link for each included script to the bottom of the container (the <head>).

Parameters:
container - element to add the script links to
scripts - scripts to add

addStylesheetsToHead

protected void addStylesheetsToHead(Element root,
                                    List<org.apache.tapestry5.internal.services.IncludedStylesheet> 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 © 2006-2009 Apache Software Foundation. All Rights Reserved.