|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tapestry.components.BlockRenderer
public class BlockRenderer
An implementation of IRender that renders a Block component.
The BlockRenderer allows the contents of a Block
to be rendered
via IRender
. It can be used in cases when an IRender
object is
required as an argument or a binding to render a part of a Component.
To provide a complicated view, it could be defined in a Block
and then
returned encapsulated in a BlockRenderer.
It is important to note that a special care has to be taken if the BlockRenderer is used within an inner class of a component or a page. In such a case the instance of the component that created the inner class may not be the currently active instance in the RequestCycle when the BlockRenderer is required. Thus, calling getComponent("blockName") to get the block component may return a Block component that is not initialized for this RequestCycle.
To avoid similar problems, the ComponentAddress class could be used in conjunction with BlockRenderer. Here is a quick example of how BlockRenderer could be used with ComponentAddress:
// Create a component address for the current component
final ComponentAddress address = new ComponentAddress(this);
return new SomeClass() {
IRender getRenderer(IRequestCycle cycle) {
MyComponent component = (MyComponent) address.findComponent(cycle);
// initialize variables in the component that will be used by the block here
return new BlockRenderer(component.getComponent("block"));
}
}
Constructor Summary | |
---|---|
BlockRenderer(Block objBlock)
Creates a new BlockRenderer that will render the content of the argument |
Method Summary | |
---|---|
void |
render(IMarkupWriter writer,
IRequestCycle cycle)
The principal rendering/rewinding method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BlockRenderer(Block objBlock)
objBlock
- the Block to be renderedMethod Detail |
---|
public void render(IMarkupWriter writer, IRequestCycle cycle)
IRender
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).
render
in interface IRender
IRender.render(IMarkupWriter, IRequestCycle)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |