com.primix.tapestry.html
Class Body

java.lang.Object
  |
  +--com.primix.tapestry.AbstractComponent
        |
        +--com.primix.tapestry.html.Body
All Implemented Interfaces:
IComponent, IRender

public class Body
extends AbstractComponent

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 before the <body> tag). This is currently used by Rollover and Script components.

Version:
$Id: Body.java,v 1.10 2001/09/04 01:27:47 hship Exp $
Author:
Howard Ship

Fields inherited from class com.primix.tapestry.AbstractComponent
id, page, specification, wrapped, wrappedCount
 
Constructor Summary
Body()
           
 
Method Summary
 void addOtherInitialization(java.lang.String script)
          Adds other initialization, in the form of additional JavaScript code to execute from the <body>'s onLoad event handler.
 void addOtherScript(java.lang.String script)
          Adds additional scripting code to the page.
static Body get(IRequestCycle cycle)
          Retrieves the Body that was stored into the request cycle.
 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.
 java.lang.String getUniqueId()
          Returns a String that is unique for the current rendering of this Body component.
 void includeScript(java.lang.String URL)
          Used to include a script from an outside URL.
 void process(ScriptSession session)
          Invoked to process the contents of a ScriptSession.
 void render(IResponseWriter writer, IRequestCycle cycle)
          The principal rendering/rewinding method.
 
Methods inherited from class com.primix.tapestry.AbstractComponent
addAsset, addComponent, addWrapped, cleanupAfterRender, cleanupComponent, finishLoad, finishLoad, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, generateAttributes, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getChangeObserver, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getListeners, getPage, getSpecification, prepareForRender, renderWrapped, reset, setBinding, setContainer, setId, setPage, setSpecification, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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.

Since:
1.0.2

addOtherInitialization

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

addOtherScript

public void addOtherScript(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 Rollover component makes use of this.

Another way this is invoked is by using the Script component.

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 addOtherInitialization(String).


includeScript

public void includeScript(java.lang.String URL)
Used to include a script from an outside URL. This adds an <script src="..."> tag before the main <script> tag. The Body component ensures that each URL is included only once.
Since:
1.0.5

get

public static Body get(IRequestCycle cycle)
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.

getUniqueId

public java.lang.String getUniqueId()
Returns a String that is unique for the current rendering of this Body component. This unique id is often appended to names to form unique ids for elements and JavaScript functions.

render

public void render(IResponseWriter writer,
                   IRequestCycle cycle)
            throws RequestCycleException
Description copied from interface: IRender
The principal rendering/rewinding method. This will cause the receiving component to render its top level elements (HTML text and components).

Renderring and rewinding are the exact same process. The same code that renders must be able to restore state by going through the exact same operations (even though the output is discarded).


process

public void process(ScriptSession session)
Invoked to process the contents of a ScriptSession.
Since:
1.0.5