|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tapestry.spec.BaseLocatable org.apache.tapestry.AbstractComponent org.apache.tapestry.html.Body
public abstract class Body
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 Rollover
and Script
components.
[Component Reference]
Constructor Summary | |
---|---|
Body()
|
Method Summary | |
---|---|
void |
addBodyScript(String script)
Adds additional scripting code to the page. |
void |
addExternalScript(IResourceLocation scriptLocation)
Used to include a script from an outside URL (the scriptLocation is a URL, probably obtained from an asset. |
void |
addInitializationScript(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, to clear any parameters back to
null (or 0, or false, or whatever the correct default is). |
protected void |
finishLoad()
Sets the element parameter property to its default, "body". |
static Body |
get(IRequestCycle cycle)
Retrieves the Body that was stored into the
request cycle. |
abstract String |
getElement()
|
String |
getPreloadedImageReference(String URL)
Adds to the script an initialization for the named variable as an Image(), to the given URL. |
String |
getUniqueString(String baseValue)
Ensures that the given string is unique. |
protected void |
renderComponent(IMarkupWriter writer,
IRequestCycle cycle)
Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)
to actually render the component (with any parameter values
already set). |
abstract void |
setElement(String element)
|
protected void |
writeScript(IMarkupWriter writer)
Writes a single large JavaScript block containing: Any image initializations Any scripting Any initializations |
Methods inherited from class org.apache.tapestry.spec.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.tapestry.ILocationHolder |
---|
setLocation |
Methods inherited from interface org.apache.tapestry.ILocatable |
---|
getLocation |
Constructor Detail |
---|
public Body()
Method Detail |
---|
public String getPreloadedImageReference(String URL)
Returns a reference, a string that can be used to represent the preloaded image in a JavaScript function.
public void addInitializationScript(String script)
onLoad
event
handler. The caller is responsible for adding a semicolon (statement
terminator). This method will add a newline after the script.
addInitializationScript
in interface IScriptProcessor
public void addBodyScript(String script)
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
addInitializationScript(String)
.
addBodyScript
in interface IScriptProcessor
public void addExternalScript(IResourceLocation scriptLocation)
addExternalScript
in interface IScriptProcessor
public static Body get(IRequestCycle cycle)
Body
that was stored into the
request cycle. This allows components wrapped by the
Body
to locate it and access the services it
provides.
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
AbstractComponent
AbstractComponent.render(IMarkupWriter, IRequestCycle)
to actually render the component (with any parameter values
already set). This is the method that subclasses must implement.
renderComponent
in class AbstractComponent
protected void cleanupAfterRender(IRequestCycle cycle)
AbstractComponent
AbstractComponent.render(IMarkupWriter, IRequestCycle)
after the component renders, to clear any parameters back to
null (or 0, or false, or whatever the correct default is).
Primarily, this is used to ensure
that the component doesn't hold onto any objects that could
otherwise be garbage collected.
Subclasses may override this implementation, but must also invoke it.
cleanupAfterRender
in class AbstractComponent
protected void writeScript(IMarkupWriter writer)
The script is written into a nested markup writer.
If there are any other initializations
(see addInitializationScript(String)
),
then a function to execute them is created.
public abstract String getElement()
public abstract void setElement(String element)
protected void finishLoad()
finishLoad
in class AbstractComponent
public String getUniqueString(String baseValue)
IScriptProcessor
getUniqueString
in interface IScriptProcessor
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |