org.apache.tapestry.util
Class PageRenderSupportImpl

java.lang.Object
  extended byorg.apache.tapestry.util.PageRenderSupportImpl
All Implemented Interfaces:
IScriptProcessor, org.apache.hivemind.Locatable, PageRenderSupport

public class PageRenderSupportImpl
extends java.lang.Object
implements org.apache.hivemind.Locatable, PageRenderSupport

Implementation of PageRenderSupport. The Body component uses an instance of this class.

Since:
4.0
Author:
Howard M. Lewis Ship

Constructor Summary
PageRenderSupportImpl(AssetFactory assetFactory, java.lang.String namespace, org.apache.hivemind.Location location)
           
 
Method Summary
 void addBodyScript(java.lang.String script)
          Adds scripting code to the main body.
 void addExternalScript(org.apache.hivemind.Resource scriptLocation)
          Adds an external script.
 void addInitializationScript(java.lang.String script)
          Adds initialization script.
 org.apache.hivemind.Location getLocation()
          Returns the location, which may be used in error messages.
 java.lang.String getPreloadedImageReference(java.lang.String URL)
          Sets up the given URL to preload, and returns a reference to the loaded image, in the form of a snippet of JavaScript expression that can be inserted into some larger block of JavaScript as a function parameter, or as a property assignment.
 java.lang.String getUniqueString(java.lang.String baseValue)
          Ensures that the given string is unique.
 void writeBodyScript(IMarkupWriter writer, IRequestCycle cycle)
          Writes a single large JavaScript block containing: Any image initializations (via getPreloadedImageReference(String)).
 void writeInitializationScript(IMarkupWriter writer)
          Writes any image initializations; this should be invoked at the end of the render, after all the related HTML will have already been streamed to the client and parsed by the web browser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PageRenderSupportImpl

public PageRenderSupportImpl(AssetFactory assetFactory,
                             java.lang.String namespace,
                             org.apache.hivemind.Location location)
Method Detail

getLocation

public org.apache.hivemind.Location getLocation()
Returns the location, which may be used in error messages. In practical terms, this is the location of the Body component.

Specified by:
getLocation in interface org.apache.hivemind.Locatable

getPreloadedImageReference

public java.lang.String getPreloadedImageReference(java.lang.String URL)
Description copied from interface: PageRenderSupport
Sets up the given URL to preload, and returns a reference to the loaded image, in the form of a snippet of JavaScript expression that can be inserted into some larger block of JavaScript as a function parameter, or as a property assignment. A typical return value might be tapestry_preload[7].src.

Specified by:
getPreloadedImageReference in interface PageRenderSupport

addBodyScript

public void addBodyScript(java.lang.String script)
Description copied from interface: IScriptProcessor
Adds scripting code to the main body. During the render, multiple scripts may render multiple bodies; all are concatinated together to form a single block. The Body component will write the body script contents just inside the <body> tag.

Specified by:
addBodyScript in interface IScriptProcessor

addInitializationScript

public void addInitializationScript(java.lang.String script)
Description copied from interface: IScriptProcessor
Adds initialization script. Initialization script is executed once, when the containing page loads. Initialization script content is written only after all HTML content that could be referenced from the script (in effect, just before the </body> tag).

Specified by:
addInitializationScript in interface IScriptProcessor

addExternalScript

public void addExternalScript(org.apache.hivemind.Resource scriptLocation)
Description copied from interface: IScriptProcessor
Adds an external script. The processor is expected to ensure that external scripts are only loaded a single time per page.

Specified by:
addExternalScript in interface IScriptProcessor

getUniqueString

public java.lang.String getUniqueString(java.lang.String baseValue)
Description copied from interface: IScriptProcessor
Ensures that the given string is unique. The string is either returned unchanged, or a suffix is appended to ensure uniqueness.

Specified by:
getUniqueString in interface IScriptProcessor

writeBodyScript

public void writeBodyScript(IMarkupWriter writer,
                            IRequestCycle cycle)
Writes a single large JavaScript block containing:

See Also:
writeInitializationScript(IMarkupWriter)

writeInitializationScript

public void writeInitializationScript(IMarkupWriter writer)
Writes any image initializations; this should be invoked at the end of the render, after all the related HTML will have already been streamed to the client and parsed by the web browser. Earlier versions of Tapestry uses a window.onload event handler.