org.apache.tapestry.html
Class Body

java.lang.Object
  extended byorg.apache.hivemind.impl.BaseLocatable
      extended byorg.apache.tapestry.AbstractComponent
          extended byorg.apache.tapestry.html.Body
All Implemented Interfaces:
IComponent, IRender, IScriptProcessor, org.apache.hivemind.Locatable, org.apache.hivemind.LocationHolder, PageRenderSupport

public abstract class Body
extends AbstractComponent
implements PageRenderSupport

The body of a Tapestry page. This is used since it allows components on the page access to an initialization script (that is written the start, just inside the <body> tag). This is currently used by Rolloverand Scriptcomponents. [ Component Reference ]

Author:
Howard Lewis Ship

Constructor Summary
Body()
           
 
Method Summary
 void addBodyScript(java.lang.String script)
          Adds additional scripting code to the page.
 void addExternalScript(org.apache.hivemind.Resource scriptLocation)
          Used to include a script from an outside URL (the scriptLocation is a URL, probably obtained from an asset.
 void addInitializationScript(java.lang.String script)
          Adds other initialization, in the form of additional JavaScript code to execute from the <body>'s onLoad event handler.
protected  void cleanupAfterRender(IRequestCycle cycle)
          Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)after the component renders.
static Body get(IRequestCycle cycle)
          Deprecated. To be removed in 4.1. Use org.apache.tapestry.TapestryUtils#getPageRenderSupport(IRequestCycle) instead.
abstract  AssetFactory getAssetFactory()
          Injected
abstract  java.lang.String getElement()
          Parameter.
 java.lang.String getPreloadedImageReference(java.lang.String URL)
          Adds to the script an initialization for the named variable as an Image(), to the given URL.
abstract  WebResponse getResponse()
          Injected
 java.lang.String getUniqueString(java.lang.String baseValue)
          Ensures that the given string is unique.
protected  void prepareForRender(IRequestCycle cycle)
          Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)to prepare the component to render.
protected  void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
          Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)to actually render the component (with any parameter values already set).
 
Methods inherited from class org.apache.tapestry.AbstractComponent
addAsset, addBody, addComponent, checkActiveLock, enterActiveState, finishLoad, finishLoad, format, format, format, format, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getBody, getBodyCount, getComponent, getComponents, getContainedComponent, getContainer, getExtendedId, getId, getIdPath, getListeners, getMessage, getMessages, getNamespace, getPage, getProperty, getSpecification, isInActiveState, isParameterBound, isRendering, pageEndRender, render, renderBody, renderInformalParameters, setBinding, setContainedComponent, setContainer, setId, setNamespace, setPage, setProperty, toString
 
Methods inherited from class org.apache.hivemind.impl.BaseLocatable
getLocation, setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.hivemind.LocationHolder
setLocation
 
Methods inherited from interface org.apache.hivemind.Locatable
getLocation
 

Constructor Detail

Body

public Body()
Method Detail

getPreloadedImageReference

public java.lang.String getPreloadedImageReference(java.lang.String URL)
Adds to the script an initialization for the named variable as an Image(), to the given URL.

Returns a reference, a string that can be used to represent the preloaded image in a JavaScript function.

Specified by:
getPreloadedImageReference in interface PageRenderSupport
Since:
1.0.2

addInitializationScript

public void addInitializationScript(java.lang.String script)
Adds other initialization, in the form of additional JavaScript code to execute from the <body>'s onLoad event handler. The caller is responsible for adding a semicolon (statement terminator). This method will add a newline after the script.

Specified by:
addInitializationScript in interface IScriptProcessor

addBodyScript

public void addBodyScript(java.lang.String script)
Adds additional scripting code to the page. This code will be added to a large block of scripting code at the top of the page (i.e., the before the <body> tag).

This is typically used to add some form of JavaScript event handler to a page. For example, the Rollovercomponent makes use of this.

Another way this is invoked is by using the Scriptcomponent.

The string will be added, as-is, within the <script> block generated by this Body component. The script should not contain HTML comments, those will be supplied by this Body component.

A frequent use is to add an initialization function using this method, then cause it to be executed using addInitializationScript(String).

Specified by:
addBodyScript in interface IScriptProcessor

addExternalScript

public void addExternalScript(org.apache.hivemind.Resource scriptLocation)
Used to include a script from an outside URL (the scriptLocation is a URL, probably obtained from an asset. This adds an <script src="..."> tag before the main <script> tag. The Body component ensures that each URL is included only once.

Specified by:
addExternalScript in interface IScriptProcessor
Since:
1.0.5

get

public static Body get(IRequestCycle cycle)
Deprecated. To be removed in 4.1. Use org.apache.tapestry.TapestryUtils#getPageRenderSupport(IRequestCycle) instead.

Retrieves the Body that was stored into the request cycle. This allows components wrapped by the Body to locate it and access the services it provides.


prepareForRender

protected void prepareForRender(IRequestCycle cycle)
Description copied from class: AbstractComponent
Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)to prepare the component to render. This implementation sets JavaBeans properties from matching bound parameters. This implementation does nothing.

Overrides:
prepareForRender in class AbstractComponent

renderComponent

protected void renderComponent(IMarkupWriter writer,
                               IRequestCycle cycle)
Description copied from class: AbstractComponent
Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)to actually render the component (with any parameter values already set). This is the method that subclasses must implement.

Specified by:
renderComponent in class AbstractComponent

cleanupAfterRender

protected void cleanupAfterRender(IRequestCycle cycle)
Description copied from class: AbstractComponent
Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)after the component renders. This implementation does nothing.

Overrides:
cleanupAfterRender in class AbstractComponent

getElement

public abstract java.lang.String getElement()
Parameter.


getAssetFactory

public abstract AssetFactory getAssetFactory()
Injected

Since:
4.0

getResponse

public abstract WebResponse getResponse()
Injected

Since:
4.0

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
Since:
3.0